version and license info in settings screen
This commit is contained in:
parent
4eb2f2bf7d
commit
c47b8120ea
|
@ -56,6 +56,7 @@
|
|||
F897AAF92200F2D200CDDD10 /* CBPeripheralState.swift in Sources */ = {isa = PBXBuildFile; fileRef = F897AAF82200F2D200CDDD10 /* CBPeripheralState.swift */; };
|
||||
F897AAFB2201018800CDDD10 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F897AAFA2201018800CDDD10 /* String.swift */; };
|
||||
F8A1584D22ECA445007F5B5D /* SettingsViewDevelopmentSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A1584C22ECA445007F5B5D /* SettingsViewDevelopmentSettingsViewModel.swift */; };
|
||||
F8A1584F22ECB281007F5B5D /* SettingsViewInfoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A1584E22ECB281007F5B5D /* SettingsViewInfoViewModel.swift */; };
|
||||
F8A54AAD22D6859200934E7A /* SlopeParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A54AAC22D6859200934E7A /* SlopeParameters.swift */; };
|
||||
F8A54AAF22D686CD00934E7A /* NightScoutBgReading.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A54AAE22D686CD00934E7A /* NightScoutBgReading.swift */; };
|
||||
F8A54AB722D9111900934E7A /* CGMTransmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A54AB322D9111900934E7A /* CGMTransmitter.swift */; };
|
||||
|
@ -223,6 +224,7 @@
|
|||
F897AAF82200F2D200CDDD10 /* CBPeripheralState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CBPeripheralState.swift; sourceTree = "<group>"; };
|
||||
F897AAFA2201018800CDDD10 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
|
||||
F8A1584C22ECA445007F5B5D /* SettingsViewDevelopmentSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewDevelopmentSettingsViewModel.swift; sourceTree = "<group>"; };
|
||||
F8A1584E22ECB281007F5B5D /* SettingsViewInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewInfoViewModel.swift; sourceTree = "<group>"; };
|
||||
F8A54AAC22D6859200934E7A /* SlopeParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlopeParameters.swift; sourceTree = "<group>"; };
|
||||
F8A54AAE22D686CD00934E7A /* NightScoutBgReading.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightScoutBgReading.swift; sourceTree = "<group>"; };
|
||||
F8A54AB322D9111900934E7A /* CGMTransmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGMTransmitter.swift; sourceTree = "<group>"; };
|
||||
|
@ -979,6 +981,7 @@
|
|||
F8B3A83D227F090D004BA588 /* SettingsViewSpeakSettingsViewModel.swift */,
|
||||
F8B3A83E227F090D004BA588 /* SettingsViewGeneralSettingsViewModel.swift */,
|
||||
F8A1584C22ECA445007F5B5D /* SettingsViewDevelopmentSettingsViewModel.swift */,
|
||||
F8A1584E22ECB281007F5B5D /* SettingsViewInfoViewModel.swift */,
|
||||
);
|
||||
path = SettingsViewModels;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1380,6 +1383,7 @@
|
|||
F8A54AB922D9111900934E7A /* CGMTransmitterDelegate.swift in Sources */,
|
||||
F8B3A856227F28DC004BA588 /* AlertTypeSettingsViewController.swift in Sources */,
|
||||
F8A54AE822D911BA00934E7A /* BatteryStatusRxMessage.swift in Sources */,
|
||||
F8A1584F22ECB281007F5B5D /* SettingsViewInfoViewModel.swift in Sources */,
|
||||
F8B3A845227F090E004BA588 /* SettingsViewDexcomSettingsViewModel.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -36,3 +36,5 @@
|
|||
"settingsviews_speakreadingslanguageselection" = "Select Language";
|
||||
"settingsviews_speakBgReadingslanguage" = "Language";
|
||||
"settingsviews_resettransmitter" = "Reset Transmitter";
|
||||
"settingsviews_Version" = "Version";
|
||||
"settingsviews_license" = "License";
|
||||
|
|
|
@ -88,4 +88,5 @@ class Texts_Common {
|
|||
static let no = {
|
||||
return NSLocalizedString("no", tableName: filename, bundle: Bundle.main, value: "no", comment: "literally no, without capital")
|
||||
}()
|
||||
|
||||
}
|
||||
|
|
|
@ -187,4 +187,14 @@ class Texts_SettingsView {
|
|||
return NSLocalizedString("settingsviews_speakRateMessage", tableName: filename, bundle: Bundle.main, value: "Value between 0 and 1", comment: "When clicking the rate setting, a pop up asks for the rate, this is the message displayed in the pop up")
|
||||
}()
|
||||
|
||||
// MARK: - Section Info
|
||||
|
||||
static let version = {
|
||||
return NSLocalizedString("settingsviews_Version", tableName: filename, bundle: Bundle.main, value: "Version", comment: "used in settings, section Info, title of the version setting")
|
||||
}()
|
||||
|
||||
static let license = {
|
||||
return NSLocalizedString("settingsviews_license", tableName: filename, bundle: Bundle.main, value: "License", comment: "used in settings, section Info, title of the license setting")
|
||||
}()
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ enum SettingsSelectedRowAction {
|
|||
/// (it's not the right place to define this, not a clear split view/model)
|
||||
case performSegue(withIdentifier: String)
|
||||
|
||||
/// to show Info to user, eg licenseInfo, with a title and a message
|
||||
///
|
||||
/// typical a pop up with a title and the message
|
||||
case showInfoText(title: String, message: String)
|
||||
|
||||
}
|
||||
|
||||
/* explanation UITableViewCell.AccessoryType
|
||||
|
|
|
@ -15,6 +15,7 @@ final class SettingsViewController: UIViewController {
|
|||
fileprivate var alarmsSettingsViewModel = SettingsViewAlertSettingsViewModel()
|
||||
fileprivate var speakSettingsViewModel = SettingsViewSpeakSettingsViewModel()
|
||||
fileprivate var developmentSettingsViewModel = SettingsViewDevelopmentSettingsViewModel()
|
||||
fileprivate var infoSettingsViewModel = SettingsViewInfoViewModel()
|
||||
|
||||
private lazy var pickerViewController: PickerViewController = {
|
||||
// Instantiate View Controller
|
||||
|
@ -133,6 +134,8 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
case healthkit
|
||||
/// store bg values in healthkit
|
||||
case speak
|
||||
/// info
|
||||
case info
|
||||
/// developper settings
|
||||
case developer
|
||||
}
|
||||
|
@ -158,6 +161,8 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
return speakSettingsViewModel.sectionTitle()
|
||||
case .developer:
|
||||
return developmentSettingsViewModel.sectionTitle()
|
||||
case .info:
|
||||
return infoSettingsViewModel.sectionTitle()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,6 +189,9 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
return speakSettingsViewModel.numberOfRows()
|
||||
case .developer:
|
||||
return developmentSettingsViewModel.numberOfRows()
|
||||
case .info:
|
||||
return infoSettingsViewModel.numberOfRows()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,6 +218,8 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
viewModel = speakSettingsViewModel
|
||||
case .developer:
|
||||
viewModel = developmentSettingsViewModel
|
||||
case .info:
|
||||
viewModel = infoSettingsViewModel
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,6 +310,8 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
viewModel = speakSettingsViewModel
|
||||
case .developer:
|
||||
viewModel = developmentSettingsViewModel
|
||||
case .info:
|
||||
viewModel = infoSettingsViewModel
|
||||
}
|
||||
|
||||
if let viewModel = viewModel {
|
||||
|
@ -362,6 +374,11 @@ extension SettingsViewController:UITableViewDataSource, UITableViewDelegate {
|
|||
|
||||
case .performSegue(let withIdentifier):
|
||||
self.performSegue(withIdentifier: withIdentifier, sender: nil)
|
||||
|
||||
case let .showInfoText(title, message):
|
||||
|
||||
UIAlertController(title: title, message: message, actionHandler: nil).presentInOwnWindow(animated: true, completion: nil)
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
import UIKit
|
||||
|
||||
fileprivate enum Setting:Int, CaseIterable {
|
||||
|
||||
/// version Number
|
||||
case versionNumber = 0
|
||||
|
||||
/// licenseInfo
|
||||
case licenseInfo = 1
|
||||
|
||||
}
|
||||
|
||||
struct SettingsViewInfoViewModel:SettingsViewModelProtocol {
|
||||
|
||||
func sectionTitle() -> String? {
|
||||
return Texts_HomeView.info
|
||||
}
|
||||
|
||||
func settingsRowText(index: Int) -> String {
|
||||
|
||||
guard let setting = Setting(rawValue: index) else { fatalError("Unexpected Section") }
|
||||
|
||||
switch setting {
|
||||
|
||||
case .versionNumber:
|
||||
|
||||
return Texts_SettingsView.version
|
||||
|
||||
case .licenseInfo:
|
||||
return Texts_SettingsView.license
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func accessoryType(index: Int) -> UITableViewCell.AccessoryType {
|
||||
|
||||
guard let setting = Setting(rawValue: index) else { fatalError("Unexpected Section") }
|
||||
|
||||
switch setting {
|
||||
|
||||
case .versionNumber:
|
||||
return UITableViewCell.AccessoryType.none
|
||||
|
||||
case .licenseInfo:
|
||||
return UITableViewCell.AccessoryType.detailButton
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func detailedText(index: Int) -> String? {
|
||||
|
||||
guard let setting = Setting(rawValue: index) else { fatalError("Unexpected Section") }
|
||||
|
||||
switch setting {
|
||||
|
||||
case .versionNumber:
|
||||
|
||||
guard let dictionary = Bundle.main.infoDictionary else {return "unknown"}
|
||||
|
||||
guard let version = dictionary["CFBundleShortVersionString"] as? String else {return "unknown"}
|
||||
|
||||
return version
|
||||
|
||||
case .licenseInfo:
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func uiView(index: Int) -> UIView? {
|
||||
return nil
|
||||
}
|
||||
|
||||
func numberOfRows() -> Int {
|
||||
return Setting.allCases.count
|
||||
}
|
||||
|
||||
func onRowSelect(index: Int) -> SettingsSelectedRowAction {
|
||||
|
||||
guard let setting = Setting(rawValue: index) else { fatalError("Unexpected Section") }
|
||||
|
||||
switch setting {
|
||||
|
||||
case .versionNumber:
|
||||
return SettingsSelectedRowAction.nothing
|
||||
|
||||
case .licenseInfo:
|
||||
|
||||
return SettingsSelectedRowAction.showInfoText(title: Constants.HomeView.applicationName, message: Texts_HomeView.licenseInfo + Constants.HomeView.infoEmailAddress)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func isEnabled(index: Int) -> Bool {
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func completeSettingsViewRefreshNeeded(index: Int) -> Bool {
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue