123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //
- // CCCreateCloud.swift
- // Nextcloud
- //
- // Created by Marino Faggiana on 14/11/18.
- // Copyright © 2017 Marino Faggiana. All rights reserved.
- //
- // Author Marino Faggiana <m.faggiana@twsweb.it>
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
- //
- import Foundation
- // MARK: -
- class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
-
- var typeTemplate = ""
- var serverUrl = ""
- var fileNameFolder = ""
- var fileName = ""
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
- @objc convenience init(typeTemplate : String) {
- self.init()
-
- self.typeTemplate = typeTemplate
- serverUrl = appDelegate.activeMain.serverUrl
-
- if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
- fileNameFolder = "/"
- } else {
- fileNameFolder = (serverUrl as NSString).lastPathComponent
- }
-
- self.initializeForm()
- }
-
- func initializeForm() {
-
- let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_upload_photos_videos_", comment: "")) as XLFormDescriptor
- form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
-
- var section : XLFormSectionDescriptor
- var row : XLFormRowDescriptor
-
- // Section: Destination Folder
-
- section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
- form.addFormSection(section)
-
- row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
- row.action.formSelector = #selector(changeDestinationFolder(_:))
-
- let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
- row.cellConfig["imageView.image"] = imageFolder
-
- row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
- row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-
- section.addFormRow(row)
-
- // Section: File Name
-
- section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
- form.addFormSection(section)
-
-
- row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
- row.value = self.fileName
-
- row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-
- row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
- row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
-
- section.addFormRow(row)
-
- self.form = form
- }
-
- // MARK: - View Life Cycle
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
-
- ocNetworking?.createTemplateRichdocuments(withTemplate: typeTemplate, success: { (listOfTemplate) in
- //
- }, failure: { (message, errorCode) in
- //
- })
-
- let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(cancel))
- let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(save))
-
- self.navigationItem.leftBarButtonItem = cancelButton
- self.navigationItem.rightBarButtonItem = saveButton
-
- self.navigationController?.navigationBar.isTranslucent = false
- self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
- self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
- self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
-
- self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
-
- self.reloadForm()
- }
-
- func reloadForm() {
-
- self.form.delegate = nil
-
- let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
- buttonDestinationFolder.title = fileNameFolder
-
- self.tableView.reloadData()
- self.form.delegate = self
- }
-
- // MARK: - Action
-
- func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String) {
-
- guard let serverUrl = serverUrl else {
- return
- }
-
- self.serverUrl = serverUrl
- if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
- fileNameFolder = "/"
- } else {
- fileNameFolder = (serverUrl as NSString).lastPathComponent
- }
- reloadForm()
- }
-
- @objc func changeDestinationFolder(_ sender: XLFormRowDescriptor) {
-
- self.deselectFormRow(sender)
-
- let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
- let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
- let viewController = navigationController.topViewController as! NCSelect
-
- viewController.delegate = self
- viewController.hideButtonCreateFolder = false
- viewController.includeDirectoryE2EEncryption = false
- viewController.includeImages = false
- viewController.layoutViewSelect = k_layout_view_move
- viewController.selectFile = false
- viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
- viewController.type = ""
- navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
- self.present(navigationController, animated: true, completion: nil)
- }
-
- @objc func save() {
-
- self.dismiss(animated: true, completion: {
-
- //self.appDelegate.activeMain.uploadFileAsset(self.assets, serverUrl: self.serverUrl, useSubFolder: useSubFolder, session: self.session)
- })
- }
-
- @objc func cancel() {
-
- self.dismiss(animated: true, completion: nil)
- }
- }
- // MARK: -
- // MARK: -
- //MARK: -
|