-
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
4 changed files
with
148 additions
and
11 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
71 changes: 71 additions & 0 deletions
71
kDrive/UI/Controller/Menu/WifiSyncSettingsViewController.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,71 @@ | ||
/* | ||
Infomaniak kDrive - iOS App | ||
Copyright (C) 2024 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 InfomaniakCoreUI | ||
import InfomaniakDI | ||
import kDriveCore | ||
import kDriveResources | ||
import UIKit | ||
|
||
class WifiSyncSettingsViewController: BaseGroupedTableViewController { | ||
@LazyInjectService private var appNavigable: AppNavigable | ||
|
||
private var tableContent: [SyncMod] = SyncMod.allCases | ||
private var selectedMod: SyncMod! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
title = KDriveResourcesStrings.Localizable.themeSettingsTitle | ||
|
||
tableView.register(cellView: SelectionTableViewCell.self) | ||
tableView.allowsMultipleSelection = false | ||
|
||
// selectedMod = UserDefaults.shared.syncMod | ||
} | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
MatomoUtils.track(view: [MatomoUtils.Views.menu.displayName, MatomoUtils.Views.settings.displayName, "SelectSyncMode"]) | ||
} | ||
|
||
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: SelectionTableViewCell.self, for: indexPath) | ||
let currentMod = tableContent[indexPath.row] | ||
if currentMod == selectedMod { | ||
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) | ||
} | ||
cell.label.text = currentMod.selectionTitle | ||
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.syncMod = mod | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Infomaniak kDrive - iOS App | ||
Copyright (C) 2024 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 kDriveResources | ||
import UIKit | ||
|
||
public enum SyncMod: String, CaseIterable { | ||
case onlyWifi | ||
case wifiAndMobileData | ||
|
||
// public var interfaceStyle: UIUserInterfaceStyle { | ||
// let styles: [Theme: UIUserInterfaceStyle] = [ | ||
// .light: .light, | ||
// .dark: .dark, | ||
// .system: .unspecified | ||
// ] | ||
// return styles[self] ?? .unspecified | ||
// } | ||
|
||
public var title: String { | ||
switch self { | ||
case .onlyWifi: | ||
return KDriveResourcesStrings.Localizable.themeSettingsLightLabel | ||
case .wifiAndMobileData: | ||
return KDriveResourcesStrings.Localizable.themeSettingsDarkLabel | ||
} | ||
} | ||
|
||
public var selectionTitle: String { | ||
switch self { | ||
case .onlyWifi: | ||
return KDriveResourcesStrings.Localizable.settingsOnlyWifiSyncDescription | ||
case .wifiAndMobileData: | ||
return "Wifi et données mobiles (à changer)" | ||
} | ||
} | ||
} |