CCShareInfoCMOC.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. @interface CCShareInfoCMOC ()
  28. @end
  29. /*
  30. #define k_permission_shared @"S"
  31. #define k_permission_can_share @"R"
  32. #define k_permission_mounted @"M"
  33. #define k_permission_file_can_write @"W"
  34. #define k_permission_can_create_file @"C"
  35. #define k_permission_can_create_folder @"K"
  36. #define k_permission_can_delete @"D"
  37. #define k_permission_can_rename @"N"
  38. #define k_permission_can_move @"V"
  39. */
  40. @implementation CCShareInfoCMOC
  41. - (void)initializeForm
  42. {
  43. XLFormDescriptor *form ;
  44. XLFormSectionDescriptor *section;
  45. XLFormRowDescriptor *row;
  46. form = [XLFormDescriptor formDescriptor];
  47. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  48. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_title_", nil)];
  49. [form addFormSection:section];
  50. if (self.metadata.directory == NO) {
  51. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"edit" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_file_can_write_", nil)];
  52. if ([self.metadata.permissions rangeOfString:k_permission_file_can_write].location != NSNotFound) row.value = @1;
  53. else row.value = @0;
  54. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  55. [row.cellConfig setObject:COLOR_BRAND forKey:@"tintColor"];
  56. [section addFormRow:row];
  57. }
  58. if (self.metadata.directory == YES) {
  59. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfile" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_file_", nil)];
  60. if ([self.metadata.permissions rangeOfString:k_permission_can_create_file].location != NSNotFound) row.value = @1;
  61. else row.value = @0;
  62. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  63. [row.cellConfig setObject:COLOR_BRAND forKey:@"tintColor"];
  64. [section addFormRow:row];
  65. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"createfolder" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_create_folder_", nil)];
  66. if ([self.metadata.permissions rangeOfString:k_permission_can_create_folder].location != NSNotFound) row.value = @1;
  67. else row.value = @0;
  68. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  69. [row.cellConfig setObject:COLOR_BRAND forKey:@"tintColor"];
  70. [section addFormRow:row];
  71. }
  72. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"delete" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_delete_", nil)];
  73. if ([self.metadata.permissions rangeOfString:k_permission_can_delete].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:COLOR_BRAND forKey:@"tintColor"];
  77. [section addFormRow:row];
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"rename" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_rename_", nil)];
  79. if ([self.metadata.permissions rangeOfString:k_permission_can_rename].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:COLOR_BRAND forKey:@"tintColor"];
  83. [section addFormRow:row];
  84. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"move" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_move_", nil)];
  85. if ([self.metadata.permissions rangeOfString:k_permission_can_move].location != NSNotFound) row.value = @1;
  86. else row.value = @0;
  87. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  88. [row.cellConfig setObject:COLOR_BRAND forKey:@"tintColor"];
  89. [section addFormRow:row];
  90. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"share" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"_share_permission_share_", nil)];
  91. if ([self.metadata.permissions rangeOfString:k_permission_can_share].location != NSNotFound) row.value = @1;
  92. else row.value = @0;
  93. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  94. [row.cellConfig setObject:COLOR_BRAND forKey:@"tintColor"];
  95. [section addFormRow:row];
  96. section = [XLFormSectionDescriptor formSection];
  97. [form addFormSection:section];
  98. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_share_permission_info_", nil)];
  99. [form addFormSection:section];
  100. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sharetype" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_share_permission_type_", nil)];
  101. if ([self.metadata.permissions rangeOfString:k_permission_shared].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_connect_you_", nil);
  102. if ([self.metadata.permissions rangeOfString:k_permission_mounted].location != NSNotFound) row.value = NSLocalizedString(@"_type_resource_external_", nil);
  103. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  104. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  105. [section addFormRow:row];
  106. self.form = form;
  107. form.disabled = YES;
  108. }
  109. - (void)viewDidLoad
  110. {
  111. [super viewDidLoad];
  112. // Color
  113. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar hidden:NO];
  114. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  115. // Done
  116. [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];
  117. self.endButton.tintColor = [COLOR_BRAND colorWithAlphaComponent:0.8];
  118. // view tint color
  119. [self.view setTintColor:COLOR_BRAND];
  120. [self initializeForm];
  121. }
  122. #pragma --------------------------------------------------------------------------------------------
  123. #pragma mark ===== Button =====
  124. #pragma --------------------------------------------------------------------------------------------
  125. - (IBAction)endButtonAction:(id)sender
  126. {
  127. [self dismissViewControllerAnimated:YES completion:nil];
  128. }
  129. @end