-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
kDrive/UI/Controller/Menu/OfflineSyncSettingsViewController.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,70 @@ | ||
/* | ||
Infomaniak kDrive - iOS App | ||
Copyright (C) 2021 Infomaniak Network SA | ||
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 kDriveCore | ||
import UIKit | ||
|
||
class OfflineSyncSettingsViewController: BaseGroupedTableViewController { | ||
private var tableContent: [SyncMod] = SyncMod.allCases | ||
private var selectedOfflineMod: SyncMod! | ||
|
||
weak var delegate: SelectPhotoFormatDelegate? | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
tableView.register(cellView: ParameterSyncTableViewCell.self) | ||
selectedOfflineMod = UserDefaults.shared.syncOfflineMod | ||
} | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
MatomoUtils.track(view: [MatomoUtils.Views.menu.displayName, MatomoUtils.Views.settings.displayName, "selectOfflineMod"]) | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return tableContent.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(type: ParameterSyncTableViewCell.self, for: indexPath) | ||
cell.initWithPositionAndShadow(isFirst: true, isLast: true) | ||
let currentMod = tableContent[indexPath.row] | ||
cell.syncTitleLabel.text = currentMod.title | ||
cell.syncDetailLabel.text = currentMod.selectionTitle | ||
if currentMod == selectedOfflineMod { | ||
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) | ||
} | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
let mod = tableContent[indexPath.row] | ||
MatomoUtils.track(eventWithCategory: .settings, name: "mod\(mod.rawValue.capitalized)") | ||
UserDefaults.shared.syncOfflineMod = mod | ||
if mod == .onlyWifi { | ||
UserDefaults.shared.isWifiOnly = true | ||
} else { | ||
UserDefaults.shared.isWifiOnly = false | ||
} | ||
navigationController?.popViewController(animated: true) | ||
} | ||
} |
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
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
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