Skip to content

Commit

Permalink
feat: Front for syncMod wifi or mobileData
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptGrv committed Sep 27, 2024
1 parent 1b60603 commit 006432d
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 44 deletions.
22 changes: 20 additions & 2 deletions kDrive/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: de, German
* Tagged: ios
* Exported by: Valentin Perignon
* Exported at: Fri, 26 Jul 2024 13:09:12 +0200
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1939,6 +1939,12 @@
/* loco:6049df4d5c2c3a04bc397a65 */
"syncConfigureTitle" = "Speichern Sie Ihre Erinnerungen an einem sicheren Ort";

/* loco:66f50ff53251a55b2f0f1532 */
"syncOnlyWifiDescription" = "Offline-Dateien werden nur mit Wi-Fi synchronisiert";

/* loco:66f50e357d4c318d780a5bd2 */
"syncOnlyWifiTitle" = "Nur mit Wi-Fi";

/* loco:6049df4d5c2c3a04bc397a66 */
"syncSettingsButtonActiveSync" = "Automatische Sicherung aktivieren";

Expand Down Expand Up @@ -1999,6 +2005,18 @@
/* loco:6049df4d5c2c3a04bc397a75 */
"syncSettingsTitle" = "Sicherung der Fotos";

/* loco:66f51084cb6715272c0b5762 */
"syncWifiAndMobileDataDescription" = "Für die mobile Datennutzung können Gebühren anfallen";

/* loco:66f50ef81220705fc30d60a2 */
"syncWifiAndMobileDataTitle" = "Mit Wi-Fi und mobilen Daten";

/* loco:66f51f3fa1ad831cda076d52 */
"syncWifiPicturesTitle" = "Fotos und Videos synchronisieren";

/* loco:66f5115224f82ae9020b3162 */
"syncWifiSettingsTitle" = "Offline-Dateien synchronisieren";

/* loco:614c87dd3af1ff4501490ec5 */
"tempDirectory" = "Temporäre Dateien";

Expand Down
22 changes: 20 additions & 2 deletions kDrive/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: en, English
* Tagged: ios
* Exported by: Valentin Perignon
* Exported at: Fri, 26 Jul 2024 13:09:12 +0200
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1939,6 +1939,12 @@
/* loco:6049df4d5c2c3a04bc397a65 */
"syncConfigureTitle" = "Save your memories in a safe place";

/* loco:66f50ff53251a55b2f0f1532 */
"syncOnlyWifiDescription" = "Offline files will be only synchronized with Wi-Fi";

/* loco:66f50e357d4c318d780a5bd2 */
"syncOnlyWifiTitle" = "With Wi-Fi only";

/* loco:6049df4d5c2c3a04bc397a66 */
"syncSettingsButtonActiveSync" = "Enable automatic backup";

Expand Down Expand Up @@ -1999,6 +2005,18 @@
/* loco:6049df4d5c2c3a04bc397a75 */
"syncSettingsTitle" = "Photo backup";

/* loco:66f51084cb6715272c0b5762 */
"syncWifiAndMobileDataDescription" = "Mobile data usage charges may apply";

/* loco:66f50ef81220705fc30d60a2 */
"syncWifiAndMobileDataTitle" = "With Wi-Fi and mobile data";

/* loco:66f51f3fa1ad831cda076d52 */
"syncWifiPicturesTitle" = "Synchronize photos and videos";

/* loco:66f5115224f82ae9020b3162 */
"syncWifiSettingsTitle" = "Synchronize offline files";

/* loco:614c87dd3af1ff4501490ec5 */
"tempDirectory" = "Temporary files";

Expand Down
22 changes: 20 additions & 2 deletions kDrive/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: es, Spanish
* Tagged: ios
* Exported by: Valentin Perignon
* Exported at: Fri, 26 Jul 2024 13:09:12 +0200
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1939,6 +1939,12 @@
/* loco:6049df4d5c2c3a04bc397a65 */
"syncConfigureTitle" = "Haz copia de seguridad de tus recuerdos en un lugar seguro";

/* loco:66f50ff53251a55b2f0f1532 */
"syncOnlyWifiDescription" = "Los archivos sin conexión sólo se sincronizarán con Wi-Fi";

/* loco:66f50e357d4c318d780a5bd2 */
"syncOnlyWifiTitle" = "Sólo con Wi-Fi";

/* loco:6049df4d5c2c3a04bc397a66 */
"syncSettingsButtonActiveSync" = "Activar la copia de seguridad automática";

Expand Down Expand Up @@ -1999,6 +2005,18 @@
/* loco:6049df4d5c2c3a04bc397a75 */
"syncSettingsTitle" = "Copia de seguridad de las fotos";

/* loco:66f51084cb6715272c0b5762 */
"syncWifiAndMobileDataDescription" = "Pueden aplicarse tarifas por uso de datos móviles";

/* loco:66f50ef81220705fc30d60a2 */
"syncWifiAndMobileDataTitle" = "Con Wi-Fi y datos móviles";

/* loco:66f51f3fa1ad831cda076d52 */
"syncWifiPicturesTitle" = "Sincronizar fotos y vídeos";

/* loco:66f5115224f82ae9020b3162 */
"syncWifiSettingsTitle" = "Sincronizar archivos sin conexión";

/* loco:614c87dd3af1ff4501490ec5 */
"tempDirectory" = "Archivos temporales";

Expand Down
22 changes: 20 additions & 2 deletions kDrive/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: fr, French
* Tagged: ios
* Exported by: Valentin Perignon
* Exported at: Fri, 26 Jul 2024 13:09:12 +0200
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1939,6 +1939,12 @@
/* loco:6049df4d5c2c3a04bc397a65 */
"syncConfigureTitle" = "Sauvegardez vos souvenirs en lieu sûr";

/* loco:66f50ff53251a55b2f0f1532 */
"syncOnlyWifiDescription" = "Les fichiers hors ligne ne seront synchronisés qu’avec le Wi-Fi";

/* loco:66f50e357d4c318d780a5bd2 */
"syncOnlyWifiTitle" = "Avec Wi-Fi uniquement";

/* loco:6049df4d5c2c3a04bc397a66 */
"syncSettingsButtonActiveSync" = "Activer la sauvegarde automatique";

Expand Down Expand Up @@ -1999,6 +2005,18 @@
/* loco:6049df4d5c2c3a04bc397a75 */
"syncSettingsTitle" = "Sauvegarde des photos";

/* loco:66f51084cb6715272c0b5762 */
"syncWifiAndMobileDataDescription" = "Des frais d’utilisation de données mobiles peuvent s’appliquer";

/* loco:66f50ef81220705fc30d60a2 */
"syncWifiAndMobileDataTitle" = "Avec Wi-Fi et données mobiles";

/* loco:66f51f3fa1ad831cda076d52 */
"syncWifiPicturesTitle" = "Synchroniser les photos et les vidéos";

/* loco:66f5115224f82ae9020b3162 */
"syncWifiSettingsTitle" = "Synchroniser des fichiers hors ligne";

/* loco:614c87dd3af1ff4501490ec5 */
"tempDirectory" = "Fichiers temporaires";

Expand Down
22 changes: 20 additions & 2 deletions kDrive/Resources/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: it, Italian
* Tagged: ios
* Exported by: Valentin Perignon
* Exported at: Fri, 26 Jul 2024 13:09:12 +0200
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1939,6 +1939,12 @@
/* loco:6049df4d5c2c3a04bc397a65 */
"syncConfigureTitle" = "Salva i tuoi ricordi in un luogo sicuro";

/* loco:66f50ff53251a55b2f0f1532 */
"syncOnlyWifiDescription" = "I file offline saranno sincronizzati solo con il Wi-Fi";

/* loco:66f50e357d4c318d780a5bd2 */
"syncOnlyWifiTitle" = "Solo con Wi-Fi";

/* loco:6049df4d5c2c3a04bc397a66 */
"syncSettingsButtonActiveSync" = "Attiva il backup automatico";

Expand Down Expand Up @@ -1999,6 +2005,18 @@
/* loco:6049df4d5c2c3a04bc397a75 */
"syncSettingsTitle" = "Backup foto";

/* loco:66f51084cb6715272c0b5762 */
"syncWifiAndMobileDataDescription" = "Potrebbero essere applicate tariffe per l’utilizzo dei dati mobili";

/* loco:66f50ef81220705fc30d60a2 */
"syncWifiAndMobileDataTitle" = "Con Wi-Fi e dati mobili";

/* loco:66f51f3fa1ad831cda076d52 */
"syncWifiPicturesTitle" = "Sincronizzare foto e video";

/* loco:66f5115224f82ae9020b3162 */
"syncWifiSettingsTitle" = "Sincronizzare i file offline";

/* loco:614c87dd3af1ff4501490ec5 */
"tempDirectory" = "File temporanei";

Expand Down
22 changes: 11 additions & 11 deletions kDrive/UI/Controller/Menu/ParameterTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ParameterTableViewController: BaseGroupedTableViewController {
case .security:
return KDriveResourcesStrings.Localizable.securityTitle
case .wifi:
return KDriveResourcesStrings.Localizable.settingsOnlyWifiSyncTitle
return KDriveResourcesStrings.Localizable.syncWifiSettingsTitle
case .storage:
return KDriveResourcesStrings.Localizable.manageStorageTitle
case .about:
Expand All @@ -78,6 +78,7 @@ class ParameterTableViewController: BaseGroupedTableViewController {
tableView.register(cellView: ParameterTableViewCell.self)
tableView.register(cellView: ParameterAboutTableViewCell.self)
tableView.register(cellView: ParameterWifiTableViewCell.self)
tableView.register(cellView: AboutDetailTableViewCell.self)

navigationItem.hideBackButtonText()
}
Expand Down Expand Up @@ -129,20 +130,19 @@ class ParameterTableViewController: BaseGroupedTableViewController {
cell.valueLabel.text = getNotificationText()
}
return cell
// case .wifi:
// let cell = tableView.dequeueReusableCell(type: ParameterWifiTableViewCell.self, for: indexPath)
// cell.initWithPositionAndShadow()
// cell.valueSwitch.isOn = UserDefaults.shared.isWifiOnly
// cell.switchHandler = { sender in
// MatomoUtils.track(eventWithCategory: .settings, name: "onlyWifiTransfer", value: sender.isOn)
// UserDefaults.shared.isWifiOnly = sender.isOn
// }
// return cell
case .wifi, .security, .storage, .about, .deleteAccount:

case .security, .storage, .about, .deleteAccount:
let cell = tableView.dequeueReusableCell(type: ParameterAboutTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0, isLast: indexPath.row == tableContent.count - 1)
cell.titleLabel.text = row.title
return cell

case .wifi:
let cell = tableView.dequeueReusableCell(type: AboutDetailTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0, isLast: indexPath.row == tableContent.count - 1)
cell.titleLabel.text = UserDefaults.shared.syncMod.title
cell.detailLabel.text = UserDefaults.shared.syncMod.selectionTitle
return cell
}
}

Expand Down
22 changes: 21 additions & 1 deletion kDrive/UI/Controller/Menu/PhotoSyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ final class PhotoSyncSettingsViewController: BaseGroupedTableViewController {
case createDatedSubFolders
case deleteAssetsAfterImport
case photoFormat
case wifiSync
}

private enum PhotoSyncDeniedRows: CaseIterable {
Expand Down Expand Up @@ -109,6 +110,7 @@ final class PhotoSyncSettingsViewController: BaseGroupedTableViewController {
tableView.register(cellView: PhotoAccessDeniedTableViewCell.self)
tableView.register(cellView: PhotoSyncSettingsTableViewCell.self)
tableView.register(cellView: PhotoFormatTableViewCell.self)
tableView.register(cellView: AboutDetailTableViewCell.self)

let view = FooterButtonView.instantiate(title: KDriveResourcesStrings.Localizable.buttonSave)
view.delegate = self
Expand Down Expand Up @@ -428,6 +430,12 @@ extension PhotoSyncSettingsViewController {
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0, isLast: indexPath.row == settingsRows.count - 1)
cell.configure(with: newSyncSettings.photoFormat)
return cell
case .wifiSync:
let cell = tableView.dequeueReusableCell(type: AboutDetailTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0, isLast: indexPath.row == settingsRows.count - 1)
cell.titleLabel.text = KDriveResourcesStrings.Localizable.syncWifiPicturesTitle
cell.detailLabel.text = UserDefaults.shared.syncMod.title
return cell
}
case .syncDenied:
switch deniedRows[indexPath.row] {
Expand Down Expand Up @@ -485,6 +493,11 @@ extension PhotoSyncSettingsViewController {
.instantiate(selectedFormat: newSyncSettings.photoFormat)
selectPhotoFormatViewController.delegate = self
navigationController?.pushViewController(selectPhotoFormatViewController, animated: true)
case .wifiSync:
let wifiSyncSettingsViewController = WifiSyncSettingsViewController
.instantiate(selectedMod: newSyncSettings.wifiSync)
wifiSyncSettingsViewController.delegate = self
navigationController?.pushViewController(wifiSyncSettingsViewController, animated: true)
default:
break
}
Expand Down Expand Up @@ -519,7 +532,7 @@ extension PhotoSyncSettingsViewController: SelectPhotoFormatDelegate {
func didSelectPhotoFormat(_ format: PhotoFileFormat) {
newSyncSettings.photoFormat = format
updateSaveButtonState()
tableView.reloadData()
tableView.reloadRows(at: [IndexPath(row: 6, section: 2)], with: .fade)
}
}

Expand Down Expand Up @@ -551,3 +564,10 @@ extension PhotoSyncSettingsViewController: PhotoSyncSettingsTableViewCellDelegat
updateSaveButtonState()
}
}

extension PhotoSyncSettingsViewController: WifiSyncSettingsDelegate {
func didSelectSyncMod(_ mod: SyncMod) {
newSyncSettings.wifiSync = mod
tableView.reloadRows(at: [IndexPath(row: 7, section: 2)], with: .fade)
}
}
24 changes: 19 additions & 5 deletions kDrive/UI/Controller/Menu/WifiSyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,32 @@ import kDriveCore
import kDriveResources
import UIKit

protocol WifiSyncSettingsDelegate: AnyObject {
func didSelectSyncMod(_ mod: SyncMod)
}

class WifiSyncSettingsViewController: BaseGroupedTableViewController {
@LazyInjectService private var appNavigable: AppNavigable

private var tableContent: [SyncMod] = SyncMod.allCases
private var selectedMod: SyncMod!
weak var delegate: WifiSyncSettingsDelegate?

override func viewDidLoad() {
super.viewDidLoad()

title = KDriveResourcesStrings.Localizable.themeSettingsTitle
title = KDriveResourcesStrings.Localizable.syncWifiSettingsTitle

tableView.register(cellView: SelectionTableViewCell.self)
tableView.register(cellView: ParameterSyncTableViewCell.self)
tableView.allowsMultipleSelection = false

// selectedMod = UserDefaults.shared.syncMod
selectedMod = UserDefaults.shared.syncMod
}

static func instantiate(selectedMod: SyncMod) -> WifiSyncSettingsViewController {
let viewController = WifiSyncSettingsViewController()
viewController.selectedMod = selectedMod
return viewController
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -53,19 +64,22 @@ class WifiSyncSettingsViewController: BaseGroupedTableViewController {
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(type: SelectionTableViewCell.self, for: indexPath)
let cell = tableView.dequeueReusableCell(type: ParameterSyncTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: true, isLast: true)
let currentMod = tableContent[indexPath.row]
if currentMod == selectedMod {
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
}
cell.label.text = currentMod.selectionTitle
cell.syncTitleLabel.text = currentMod.title
cell.syncDetailLabel.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
delegate?.didSelectSyncMod(tableContent[indexPath.row])
navigationController?.popViewController(animated: true)
}
}
Loading

0 comments on commit 006432d

Please sign in to comment.