-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#351 added first draft of Sharing with users, groups, remotes
- Loading branch information
Showing
11 changed files
with
500 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
ownCloud/Client/Sharing/SharingEditUserGroupsTableViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// | ||
// SharingEditUserGroupsTableViewController.swift | ||
// ownCloud | ||
// | ||
// Created by Matthias Hühne on 10.04.19. | ||
// Copyright © 2019 ownCloud GmbH. All rights reserved. | ||
// | ||
|
||
/* | ||
* Copyright (C) 2019, ownCloud GmbH. | ||
* | ||
* This code is covered by the GNU Public License Version 3. | ||
* | ||
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/ | ||
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
* | ||
*/ | ||
|
||
import UIKit | ||
import ownCloudSDK | ||
|
||
class SharingEditUserGroupsTableViewController: StaticTableViewController { | ||
|
||
var share : OCShare? | ||
var reshares : [OCShare]? | ||
var showSubtitles : Bool = false | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.navigationItem.title = share?.recipient!.displayName! | ||
|
||
let infoButton = UIButton(type: .infoLight) | ||
infoButton.addTarget(self, action: #selector(showInfoSubtitles), for: .touchUpInside) | ||
let infoBarButtonItem = UIBarButtonItem(customView: infoButton) | ||
navigationItem.rightBarButtonItem = infoBarButtonItem | ||
|
||
loadPermissionRow() | ||
loadReshares() | ||
} | ||
|
||
func loadPermissionRow() { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateStyle = .medium | ||
dateFormatter.timeStyle = .short | ||
var footer = "" | ||
if let date = share?.creationDate { | ||
footer = "Shared since: \(dateFormatter.string(from: date))" | ||
} | ||
|
||
let section = StaticTableViewSection(headerTitle: "Permissions".localized, footerTitle: footer, identifier: "permission-section") | ||
guard let share = share else { return } | ||
var permissions : [[String: Bool]] = [] | ||
var subtitles : [String]? | ||
|
||
if share.itemType == .collection { | ||
permissions = [ | ||
["Share" : share.canShare], | ||
["Edit" : share.canReadWrite], | ||
["Create" : share.canCreate], | ||
["Change" : share.canUpdate], | ||
["Delete" : share.canDelete] | ||
] | ||
if showSubtitles { | ||
subtitles = [ | ||
"Allows the users you share with to re-share".localized, | ||
"Allows the users you share with to edit your shared files, and to collaborate".localized, | ||
"Allows the users you share with to create new files and add them to the share".localized, | ||
"Allows uploading a new version of a shared file and replacing it".localized, | ||
"Allows the users you share with to delete shared files".localized | ||
] | ||
} | ||
} else { | ||
permissions = [ | ||
["Share" : share.canShare], | ||
["Edit" : share.canReadWrite], | ||
["Change" : share.canUpdate] | ||
] | ||
if showSubtitles { | ||
subtitles = [ | ||
"Allows the users you share with to re-share".localized, | ||
"Allows the users you share with to edit your shared files, and to collaborate".localized, | ||
"Allows uploading a new version of a shared file and replacing it".localized | ||
] | ||
} | ||
} | ||
|
||
section.add(toogleGroupWithArrayOfLabelValueDictionaries: permissions, radioAction: { (row, _) in | ||
let selectedValueFromSection = row.section?.selectedValue(forGroupIdentifier: row.groupIdentifier!) | ||
|
||
Log.log("Radio value for \(row.groupIdentifier!) changed to \(row.value!)") | ||
Log.log("Values can also be read from the section object: \(selectedValueFromSection!)") | ||
|
||
}, subtitles: subtitles, groupIdentifier: "radioExample", selectedValue:true) | ||
self.insertSection(section, at: 0, animated: false) | ||
//self.addSection(section) | ||
} | ||
|
||
func loadReshares() { | ||
var shareRows: [StaticTableViewRow] = [] | ||
|
||
if let reshares = reshares, reshares.count > 0 { | ||
for share in reshares { | ||
shareRows.append( StaticTableViewRow(rowWithAction: { (_, _) in | ||
let editSharingViewController = SharingEditUserGroupsTableViewController(style: .grouped) | ||
editSharingViewController.share = share | ||
self.navigationController?.pushViewController(editSharingViewController, animated: true) | ||
}, title: share.recipient!.displayName!, subtitle: "Share, Edit, Change", accessoryType: .disclosureIndicator) ) | ||
} | ||
|
||
let section = StaticTableViewSection(headerTitle: "Shared to".localized, footerTitle: nil, rows: shareRows) | ||
self.addSection(section) | ||
} | ||
|
||
let section = StaticTableViewSection(headerTitle: nil, footerTitle: nil) | ||
section.add(rows: [ | ||
StaticTableViewRow(buttonWithAction: { (_, _) in | ||
Log.log("Destructive pressed") | ||
}, title: "Revoke Recipient", style: StaticTableViewRowButtonStyle.destructive) | ||
]) | ||
|
||
self.addSection(section) | ||
} | ||
|
||
@objc func showInfoSubtitles() { | ||
showSubtitles.toggle() | ||
guard let removeSection = self.sectionForIdentifier("permission-section") else { return } | ||
self.removeSection(removeSection) | ||
loadPermissionRow() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
ownCloud/Client/Sharing/SharingSearchResultsTableViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// SharingSearchResultsTableViewController.swift | ||
// ownCloud | ||
// | ||
// Created by Matthias Hühne on 11.04.19. | ||
// Copyright © 2019 ownCloud GmbH. All rights reserved. | ||
// | ||
|
||
/* | ||
* Copyright (C) 2019, ownCloud GmbH. | ||
* | ||
* This code is covered by the GNU Public License Version 3. | ||
* | ||
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/ | ||
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
* | ||
*/ | ||
|
||
import UIKit | ||
|
||
class SharingSearchResultsTableViewController: StaticTableViewController, UISearchResultsUpdating { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
} | ||
|
||
// MARK: - UISearchResultsUpdating Delegate | ||
func updateSearchResults(for searchController: UISearchController) { | ||
} | ||
} |
Oops, something went wrong.