CCCreateCloud.swift 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //
  2. // CCCreateCloud.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 09/01/17.
  6. // Copyright © 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 Foundation
  24. // MARK: - CreateMenuAdd
  25. class CreateMenuAdd: NSObject {
  26. let fontButton = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 14)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 65.0/255.0, green: 64.0/255.0, blue: 66.0/255.0, alpha: 1.0)]
  27. let fontEncrypted = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 14)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 241.0/255.0, green: 90.0/255.0, blue: 34.0/255.0, alpha: 1.0)]
  28. let fontCancel = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 16)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 1.0)]
  29. let colorLightGray = UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1)
  30. func createMenuPlain(view : UIView) {
  31. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  32. let actionSheet = AHKActionSheet.init(view: view, title: nil)
  33. actionSheet?.animationDuration = 0.2
  34. actionSheet?.cancelOnTapEmptyAreaEnabled = 1
  35. actionSheet?.automaticallyTintButtonImages = 0
  36. actionSheet?.blurRadius = 0.0
  37. actionSheet?.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  38. actionSheet?.buttonHeight = 50.0
  39. actionSheet?.cancelButtonHeight = 50.0
  40. actionSheet?.separatorHeight = 5.0
  41. actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
  42. actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  43. actionSheet?.buttonTextAttributes = fontButton
  44. actionSheet?.encryptedButtonTextAttributes = fontEncrypted
  45. actionSheet?.cancelButtonTextAttributes = fontCancel
  46. actionSheet?.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  47. actionSheet?.addButton(withTitle: "Create a new folder", image: UIImage(named: "createFolderNextcloud"), backgroundColor: UIColor.white, height: 50.0 ,type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  48. appDelegate.activeMain.returnCreate(Int(returnCreateFolderPlain))
  49. })
  50. actionSheet?.addButton(withTitle: "Upload photos and videos", image: UIImage(named: "uploadPhotoNextcloud"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  51. appDelegate.activeMain.returnCreate(Int(returnCreateFotoVideoPlain))
  52. })
  53. actionSheet?.addButton(withTitle: "Upload a file", image: UIImage(named: "uploadFileNextcloud"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  54. appDelegate.activeMain.returnCreate(Int(returnCreateFilePlain))
  55. })
  56. actionSheet?.addButton(withTitle: "Upload Encrypted mode", image: UIImage(named: "actionSheetLock"), backgroundColor: colorLightGray, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  57. self.createMenuEncrypted(view: view)
  58. })
  59. actionSheet?.show()
  60. }
  61. func createMenuEncrypted(view : UIView) {
  62. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  63. let actionSheet = AHKActionSheet.init(view: view, title: nil)
  64. actionSheet?.animationDuration = 0.2
  65. actionSheet?.cancelOnTapEmptyAreaEnabled = 1
  66. actionSheet?.blurRadius = 0.0
  67. actionSheet?.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  68. actionSheet?.buttonHeight = 50.0
  69. actionSheet?.cancelButtonHeight = 50.0
  70. actionSheet?.separatorHeight = 5.0
  71. actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
  72. actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  73. actionSheet?.buttonTextAttributes = fontButton
  74. actionSheet?.encryptedButtonTextAttributes = fontEncrypted
  75. actionSheet?.cancelButtonTextAttributes = fontCancel
  76. actionSheet?.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  77. actionSheet?.addButton(withTitle: "Create a new folder", image: UIImage(named: "foldercrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  78. appDelegate.activeMain.returnCreate(Int(returnCreateFolderEncrypted))
  79. })
  80. actionSheet?.addButton(withTitle: "Upload photos and videos", image: UIImage(named: "photocrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  81. appDelegate.activeMain.returnCreate(Int(returnCreateFotoVideoEncrypted))
  82. })
  83. actionSheet?.addButton(withTitle: "Upload a file", image: UIImage(named: "importCloudCrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  84. appDelegate.activeMain.returnCreate(Int(returnCreateFileEncrypted))
  85. })
  86. actionSheet?.addButton(withTitle: NSLocalizedString("Upload Template", comment: ""), image: UIImage(named: "template"), backgroundColor: colorLightGray, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  87. self.createMenuTemplate(view: view)
  88. })
  89. actionSheet?.show()
  90. }
  91. func createMenuTemplate(view : UIView) {
  92. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  93. let actionSheet = AHKActionSheet.init(view: view, title: nil)
  94. actionSheet?.animationDuration = 0.2
  95. actionSheet?.cancelOnTapEmptyAreaEnabled = 1
  96. actionSheet?.blurRadius = 0.0
  97. actionSheet?.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  98. actionSheet?.buttonHeight = 50.0
  99. actionSheet?.cancelButtonHeight = 50.0
  100. actionSheet?.separatorHeight = 5.0
  101. actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
  102. actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  103. actionSheet?.buttonTextAttributes = fontButton
  104. actionSheet?.encryptedButtonTextAttributes = fontEncrypted
  105. actionSheet?.cancelButtonTextAttributes = fontCancel
  106. actionSheet?.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  107. actionSheet?.addButton(withTitle: NSLocalizedString("_add_notes_", comment: ""), image: UIImage(named: "note"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  108. appDelegate.activeMain.returnCreate(Int(returnNote))
  109. })
  110. actionSheet?.addButton(withTitle: NSLocalizedString("_add_web_account_", comment: ""), image: UIImage(named: "baseurl"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  111. appDelegate.activeMain.returnCreate(Int(returnAccountWeb))
  112. })
  113. actionSheet?.addButton(withTitle: "", image: nil, backgroundColor: UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1), height: 10.0, type: AHKActionSheetButtonType.disabled, handler: {(AHKActionSheet) -> Void in
  114. print("disable")
  115. })
  116. actionSheet?.addButton(withTitle: NSLocalizedString("_add_credit_card_", comment: ""), image: UIImage(named: "cartadicredito"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  117. appDelegate.activeMain.returnCreate(Int(returnCartaDiCredito))
  118. })
  119. actionSheet?.addButton(withTitle: NSLocalizedString("_add_atm_", comment: ""), image: UIImage(named: "bancomat"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  120. appDelegate.activeMain.returnCreate(Int(returnBancomat))
  121. })
  122. actionSheet?.addButton(withTitle: NSLocalizedString("_add_bank_account_", comment: ""), image: UIImage(named: "contocorrente"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  123. appDelegate.activeMain.returnCreate(Int(returnContoCorrente))
  124. })
  125. actionSheet?.addButton(withTitle: "", image: nil, backgroundColor: UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1), height: 10.0, type: AHKActionSheetButtonType.disabled, handler: {(AHKActionSheet) -> Void in
  126. print("disable")
  127. })
  128. actionSheet?.addButton(withTitle: NSLocalizedString("_add_driving_license_", comment: ""), image: UIImage(named: "patenteguida"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  129. appDelegate.activeMain.returnCreate(Int(returnPatenteGuida))
  130. })
  131. actionSheet?.addButton(withTitle: NSLocalizedString("_add_id_card_", comment: ""), image: UIImage(named: "cartaidentita"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  132. appDelegate.activeMain.returnCreate(Int(returnCartaIdentita))
  133. })
  134. actionSheet?.addButton(withTitle: NSLocalizedString("_add_passport_", comment: ""), image: UIImage(named: "passaporto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  135. appDelegate.activeMain.returnCreate(Int(returnPassaporto))
  136. })
  137. actionSheet?.show()
  138. }
  139. }
  140. // MARK: - CreateFormUpload
  141. class CreateFormUpload: XLFormViewController {
  142. var destinationFolder : String?
  143. convenience init(_ destionationFolder : String?) {
  144. self.init()
  145. if destionationFolder == nil || destionationFolder?.isEmpty == true {
  146. self.destinationFolder = "/" //NSLocalizedString("_root_", comment: "")
  147. } else {
  148. self.destinationFolder = destionationFolder
  149. }
  150. self.initializeForm()
  151. }
  152. override func viewDidLoad() {
  153. super.viewDidLoad()
  154. let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(cancel))
  155. let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(save))
  156. self.navigationItem.leftBarButtonItem = cancelButton
  157. self.navigationItem.rightBarButtonItem = saveButton
  158. }
  159. func initializeForm() {
  160. let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
  161. form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
  162. var section : XLFormSectionDescriptor
  163. var row : XLFormRowDescriptor
  164. section = XLFormSectionDescriptor.formSection(withTitle: "_destination_folder_") as XLFormSectionDescriptor
  165. form.addFormSection(section)
  166. row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.destinationFolder)
  167. row.cellConfig.setObject(UIImage(named: image_settingsManagePhotos)!, forKey: "imageView.image" as NSCopying)
  168. section.addFormRow(row)
  169. section = XLFormSectionDescriptor.formSection(withTitle: "A") as XLFormSectionDescriptor
  170. form.addFormSection(section)
  171. row = XLFormRowDescriptor(tag: "FolderPhoto", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: "Save in Pfoto folder")
  172. section.addFormRow(row)
  173. row = XLFormRowDescriptor(tag: "der", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: "Subloder")
  174. section.addFormRow(row)
  175. section = XLFormSectionDescriptor.formSection(withTitle: "B") as XLFormSectionDescriptor
  176. form.addFormSection(section)
  177. row = XLFormRowDescriptor(tag: "TextFieldAndTextView", rowType: XLFormRowDescriptorTypeName, title: "File name")
  178. section.addFormRow(row)
  179. self.form = form
  180. }
  181. func save() {
  182. }
  183. func cancel() {
  184. }
  185. }