CCShareInfoCMOC.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // CCShareInfoCMOC.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 07/03/16.
  6. // Copyright (c) 2017 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. #import "NCBridgeSwift.h"
  28. @interface CCShareInfoCMOC ()
  29. @end
  30. /*
  31. #define k_permission_shared @"S"
  32. #define k_permission_can_share @"R"
  33. #define k_permission_mounted @"M"
  34. #define k_permission_file_can_write @"W"
  35. #define k_permission_can_create_file @"C"
  36. #define k_permission_can_create_folder @"K"
  37. #define k_permission_can_delete @"D"
  38. #define k_permission_can_rename @"N"
  39. #define k_permission_can_move @"V"
  40. */
  41. @implementation CCShareInfoCMOC
  42. - (instancetype)initWithCoder:(NSCoder *)coder
  43. {
  44. self = [super initWithCoder:coder];
  45. if (self) {
  46. [self initializeForm];
  47. }
  48. return self;
  49. }
  50. - (void)initializeForm
  51. {
  52. XLFormDescriptor *form ;
  53. XLFormSectionDescriptor *section;
  54. XLFormRowDescriptor *row;
  55. form = [XLFormDescriptor formDescriptor];
  56. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  57. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_title_", nil)];
  58. [form addFormSection:section];
  59. if (self.metadata.directory == NO) {
  60. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"edit" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_file_can_write_", nil)];
  61. if ([self.metadata.permissions rangeOfString:k_permission_file_can_write].location != NSNotFound) row.value = @1;
  62. else row.value = @0;
  63. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  64. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  65. [section addFormRow:row];
  66. }
  67. if (self.metadata.directory == YES) {
  68. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfile" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_file_", nil)];
  69. if ([self.metadata.permissions rangeOfString:k_permission_can_create_file].location != NSNotFound) row.value = @1;
  70. else row.value = @0;
  71. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  72. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  73. [section addFormRow:row];
  74. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfolder" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_folder_", nil)];
  75. if ([self.metadata.permissions rangeOfString:k_permission_can_create_folder].location != NSNotFound) row.value = @1;
  76. else row.value = @0;
  77. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  78. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  79. [section addFormRow:row];
  80. }
  81. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"delete" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_delete_", nil)];
  82. if ([self.metadata.permissions rangeOfString:k_permission_can_delete].location != NSNotFound) row.value = @1;
  83. else row.value = @0;
  84. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  85. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  86. [section addFormRow:row];
  87. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"rename" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_rename_", nil)];
  88. if ([self.metadata.permissions rangeOfString:k_permission_can_rename].location != NSNotFound) row.value = @1;
  89. else row.value = @0;
  90. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  91. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  92. [section addFormRow:row];
  93. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"move" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_move_", nil)];
  94. if ([self.metadata.permissions rangeOfString:k_permission_can_move].location != NSNotFound) row.value = @1;
  95. else row.value = @0;
  96. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  97. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  98. [section addFormRow:row];
  99. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"share" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_share_", nil)];
  100. if ([self.metadata.permissions rangeOfString:k_permission_can_share].location != NSNotFound) row.value = @1;
  101. else row.value = @0;
  102. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  103. [row.cellConfig setObject:[NCBrandColor sharedInstance].brand forKey:@"tintColor"];
  104. [section addFormRow:row];
  105. section = [XLFormSectionDescriptor formSection];
  106. [form addFormSection:section];
  107. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_info_", nil)];
  108. [form addFormSection:section];
  109. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sharetype" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_share_permission_type_", nil)];
  110. if ([self.metadata.permissions rangeOfString:k_permission_shared].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_connect_you_", nil);
  111. if ([self.metadata.permissions rangeOfString:k_permission_mounted].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_external_", nil);
  112. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  113. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  114. [section addFormRow:row];
  115. self.form = form;
  116. form.disabled = YES;
  117. }
  118. - (void)viewDidLoad
  119. {
  120. [super viewDidLoad];
  121. self.view.backgroundColor = [NCBrandColor sharedInstance].tableBackground;
  122. [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];
  123. self.endButton.tintColor = [NCBrandColor sharedInstance].brand;
  124. self.tableView.backgroundColor = [NCBrandColor sharedInstance].tableBackground;
  125. }
  126. #pragma --------------------------------------------------------------------------------------------
  127. #pragma mark ===== Button =====
  128. #pragma --------------------------------------------------------------------------------------------
  129. - (IBAction)endButtonAction:(id)sender
  130. {
  131. [self dismissViewControllerAnimated:YES completion:nil];
  132. }
  133. @end