CCShareInfoCMOC.m 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // CCShareInfoCMOC.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 07/03/16.
  6. // Copyright (c) 2014 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCShareInfoCMOC.h"
  24. #import "XLFormViewController.h"
  25. #import "XLForm.h"
  26. #import "AppDelegate.h"
  27. #ifdef CUSTOM_BUILD
  28. #import "CustomSwift.h"
  29. #else
  30. #import "Nextcloud-Swift.h"
  31. #endif
  32. @interface CCShareInfoCMOC ()
  33. @end
  34. /*
  35. #define k_permission_shared @"S"
  36. #define k_permission_can_share @"R"
  37. #define k_permission_mounted @"M"
  38. #define k_permission_file_can_write @"W"
  39. #define k_permission_can_create_file @"C"
  40. #define k_permission_can_create_folder @"K"
  41. #define k_permission_can_delete @"D"
  42. #define k_permission_can_rename @"N"
  43. #define k_permission_can_move @"V"
  44. */
  45. @implementation CCShareInfoCMOC
  46. - (instancetype)initWithCoder:(NSCoder *)coder
  47. {
  48. self = [super initWithCoder:coder];
  49. if (self) {
  50. [self initializeForm];
  51. }
  52. return self;
  53. }
  54. - (void)initializeForm
  55. {
  56. XLFormDescriptor *form ;
  57. XLFormSectionDescriptor *section;
  58. XLFormRowDescriptor *row;
  59. form = [XLFormDescriptor formDescriptor];
  60. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  61. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_title_", nil)];
  62. [form addFormSection:section];
  63. if (self.metadata.directory == NO) {
  64. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"edit" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_file_can_write_", nil)];
  65. if ([self.metadata.permissions rangeOfString:k_permission_file_can_write].location != NSNotFound) row.value = @1;
  66. else row.value = @0;
  67. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  68. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  69. [section addFormRow:row];
  70. }
  71. if (self.metadata.directory == YES) {
  72. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfile" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_file_", nil)];
  73. if ([self.metadata.permissions rangeOfString:k_permission_can_create_file].location != NSNotFound) row.value = @1;
  74. else row.value = @0;
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  76. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  77. [section addFormRow:row];
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfolder" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_folder_", nil)];
  79. if ([self.metadata.permissions rangeOfString:k_permission_can_create_folder].location != NSNotFound) row.value = @1;
  80. else row.value = @0;
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  82. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  83. [section addFormRow:row];
  84. }
  85. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"delete" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_delete_", nil)];
  86. if ([self.metadata.permissions rangeOfString:k_permission_can_delete].location != NSNotFound) row.value = @1;
  87. else row.value = @0;
  88. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  89. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  90. [section addFormRow:row];
  91. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"rename" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_rename_", nil)];
  92. if ([self.metadata.permissions rangeOfString:k_permission_can_rename].location != NSNotFound) row.value = @1;
  93. else row.value = @0;
  94. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  95. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  96. [section addFormRow:row];
  97. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"move" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_move_", nil)];
  98. if ([self.metadata.permissions rangeOfString:k_permission_can_move].location != NSNotFound) row.value = @1;
  99. else row.value = @0;
  100. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  101. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  102. [section addFormRow:row];
  103. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"share" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_share_", nil)];
  104. if ([self.metadata.permissions rangeOfString:k_permission_can_share].location != NSNotFound) row.value = @1;
  105. else row.value = @0;
  106. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  107. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  108. [section addFormRow:row];
  109. section = [XLFormSectionDescriptor formSection];
  110. [form addFormSection:section];
  111. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_info_", nil)];
  112. [form addFormSection:section];
  113. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sharetype" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_share_permission_type_", nil)];
  114. if ([self.metadata.permissions rangeOfString:k_permission_shared].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_connect_you_", nil);
  115. if ([self.metadata.permissions rangeOfString:k_permission_mounted].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_external_", nil);
  116. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  117. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  118. [section addFormRow:row];
  119. self.form = form;
  120. form.disabled = YES;
  121. }
  122. - (void)viewDidLoad
  123. {
  124. [super viewDidLoad];
  125. self.view.backgroundColor = [NCBrandColor sharedInstance].tableBackground;
  126. [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];
  127. self.endButton.tintColor = [NCBrandColor sharedInstance].brand;
  128. self.tableView.backgroundColor = [NCBrandColor sharedInstance].tableBackground;
  129. }
  130. #pragma --------------------------------------------------------------------------------------------
  131. #pragma mark ===== Button =====
  132. #pragma --------------------------------------------------------------------------------------------
  133. - (IBAction)endButtonAction:(id)sender
  134. {
  135. [self dismissViewControllerAnimated:YES completion:nil];
  136. }
  137. @end