Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Settings view #34

Merged
merged 63 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6626ec9
chore: Settings i18n
adrien-coye Oct 31, 2024
46174e2
feat: SettingsView first draft
adrien-coye Oct 31, 2024
e31f4b9
feat: Using more i18n
adrien-coye Oct 31, 2024
c586eaf
feat: Reworked the datasource of the settings view
adrien-coye Nov 1, 2024
f1aed47
feat: Setting detail screen
adrien-coye Nov 1, 2024
5d5db98
refactor: Reworked settings datasource
adrien-coye Nov 4, 2024
73bb7fd
feat: Banner on setting detail
adrien-coye Nov 5, 2024
2011def
chore: PR Feedback on using directly the STCoreTypes without abstraction
adrien-coye Nov 5, 2024
fbb1890
feat: Settings links
adrien-coye Nov 5, 2024
b72e65c
chore: More localization
adrien-coye Nov 5, 2024
43b79ac
feat: App version generated from CorePlatform code.
adrien-coye Nov 5, 2024
e1e3940
feat: Settings toggle logic
adrien-coye Nov 7, 2024
b3add49
feat: Settings detail view can display a checkmark on the currently s…
adrien-coye Nov 8, 2024
c24e080
chore: Adding i18n for notification settings, unig the new keys
adrien-coye Nov 11, 2024
c2f5582
feat: Using the Infomaniak Core ReviewManager
adrien-coye Nov 11, 2024
d582acb
feat: PR Feedback
adrien-coye Nov 11, 2024
f6de819
chore: Merge branch 'main' into settings_view
adrien-coye Nov 11, 2024
7879a0a
chore: Sonar feedback
adrien-coye Nov 11, 2024
62bc503
feat: Missing i18n in ValidityPeriod
adrien-coye Nov 11, 2024
aaf3b87
chore: PR Feedback, disgarding init for use of var in views instead
adrien-coye Nov 12, 2024
6e6be2b
chore: PR Feedback
adrien-coye Nov 12, 2024
9a9cb46
refactor: Abstract Root Settings datasource
adrien-coye Nov 12, 2024
fba792c
refactor: Shared code between SettingsView and NewTransferSettingsView
adrien-coye Nov 12, 2024
ff69605
feat: Extra i18n for personalized notifications
adrien-coye Nov 12, 2024
82e7378
feat: Notification setting label
adrien-coye Nov 13, 2024
02abf22
chore: PR Feedback
adrien-coye Nov 13, 2024
51f241f
refactor: Changed NewTransferSettingCell init
adrien-coye Nov 13, 2024
ca41b81
chore: PR Feedback
adrien-coye Nov 13, 2024
93a91c2
chore: Merge branch 'settings_view' into settings_view_g
adrien-coye Nov 13, 2024
d8112d9
feat: New optionalTag view modifier
adrien-coye Nov 13, 2024
bb6d583
chore: Sonar Feedback
adrien-coye Nov 13, 2024
b1f5bd4
chore: PR Feedback
adrien-coye Nov 13, 2024
a18c1f2
refactor: Rename data used to display a setting view with correct naming
adrien-coye Nov 13, 2024
44f251c
fix: NewTransferSetting view works
adrien-coye Nov 13, 2024
99a9ba6
Merge pull request #41 from Infomaniak/settings_view_g
adrien-coye Nov 13, 2024
17ad0b5
chore: Merge branch 'main' into settings_view
adrien-coye Nov 13, 2024
b8aebb7
chore: Linter feedback
adrien-coye Nov 13, 2024
8c066fd
refactor: SettingsView as a static MV view
adrien-coye Nov 18, 2024
f2bb63d
refactor: Rollback data structure driven view
adrien-coye Nov 18, 2024
98f7a1b
chore: Merge branch 'main' into settings_view
adrien-coye Nov 18, 2024
ebd5f35
refactor: Generic setting detail view
adrien-coye Nov 18, 2024
b904d1a
chore: Cleared assets duplicated during previous merge
adrien-coye Nov 18, 2024
e0201fe
chore: PR Feedback
adrien-coye Nov 18, 2024
3705063
chore: PR Feedback
adrien-coye Nov 19, 2024
2152292
refactor: Dedicated notification settings cell that tracks the settin…
adrien-coye Nov 19, 2024
628c5d2
chore: PR Feedback
adrien-coye Nov 19, 2024
0109e97
refactor: SettingSelectable extension to store a setting for conformi…
adrien-coye Nov 19, 2024
d41b605
refactor: Dedicated views in dedicated files
adrien-coye Nov 19, 2024
a95ceb0
chore: PR Feedback
adrien-coye Nov 20, 2024
b5cf3f4
feat: Standard toolbar modifier
adrien-coye Nov 20, 2024
50a8f5c
chore: PR Feedback on ordering of property wrappers
adrien-coye Nov 20, 2024
abd63ab
chore: Notification toggle behaviour changed
adrien-coye Nov 21, 2024
b6613e0
refactor: Assets are colored with code
adrien-coye Nov 21, 2024
30a186a
chore: Sonar Feedback
adrien-coye Nov 21, 2024
769e785
chore: PR Feedback
adrien-coye Nov 21, 2024
4f1d8ad
chore: Linter
adrien-coye Nov 21, 2024
2e0a730
chore: PR Feedback
adrien-coye Nov 22, 2024
92ef4ae
chore: PR Feedback
adrien-coye Nov 22, 2024
83be402
fix: Remove previous hack to get System theme working
adrien-coye Nov 22, 2024
0f0ffca
chore: PR Feedback
adrien-coye Nov 22, 2024
f23d655
chore: Revert "chore: PR Feedback"
adrien-coye Nov 22, 2024
ed8e21f
chore: PR Feedback
adrien-coye Nov 22, 2024
b9aaafe
chore: PR Feedback
adrien-coye Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions SwissTransfer/Sources/SwissTransferApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,43 @@
*/

import InfomaniakCoreSwiftUI
import InfomaniakDI
import STCore
import STResources
import STRootView
import SwiftUI
import SwissTransferCore
import SwissTransferCoreUI

@main
struct SwissTransferApp: App {
private let dependencyInjectionHook = TargetAssembly()

@LazyInjectService private var settingsManager: AppSettingsManager
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved

@StateObject var appSettings: FlowObserver<AppSettings>
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
@Environment(\.colorScheme) var colorScheme

var savedScheme: ColorScheme? {
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
guard let appSettings = appSettings.value,
let storedColorScheme = ColorScheme.from(appSettings.theme) else {
return colorScheme
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
}

return storedColorScheme
}

public init() {
@InjectService var settingsManager: AppSettingsManager
_appSettings = StateObject(wrappedValue: FlowObserver(flow: settingsManager.appSettings))
}

var body: some Scene {
WindowGroup {
RootView()
.tint(.ST.primary)
.detectCompactWindow()
.preferredColorScheme(savedScheme)
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
29 changes: 29 additions & 0 deletions SwissTransferCore/Navigation.swift
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Infomaniak SwissTransfer - 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 Foundation

/// All the sub-screens accessible from the settings view.
public enum SettingDetailUi: Hashable {
case theme
case notifications
case validityPeriod
case downloadLimit
case emailLanguage
case dataManagement
}
3 changes: 1 addition & 2 deletions SwissTransferCore/NavigationDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

import STCore

// TODO: Will be updated with the Settings item
public enum NavigationDestination: Hashable {
case transfer(TransferUi)
case settings
case settings(SettingDetailUi)

public static func == (lhs: NavigationDestination, rhs: NavigationDestination) -> Bool {
switch (lhs, rhs) {
Expand Down
48 changes: 48 additions & 0 deletions SwissTransferCoreUI/Extensions/ColorScheme+Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Infomaniak SwissTransfer - 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 STCore
import STResources
import SwiftUI

public extension Theme {
var localized: String {
switch self {
case .dark:
return STResourcesStrings.Localizable.settingsOptionThemeDark
case .light:
return STResourcesStrings.Localizable.settingsOptionThemeLight
case .system:
return STResourcesStrings.Localizable.settingsOptionThemeSystem
}
}
}

public extension ColorScheme {
/// STCore `Theme` to SwiftUI `ColorScheme` bridge
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
static func from(_ theme: Theme) -> ColorScheme? {
switch theme {
case .system:
return nil
case .light:
return .light
case .dark:
return .dark
}
}
}
46 changes: 46 additions & 0 deletions SwissTransferFeatures/SettingsView/Cells/EditSettingsCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Infomaniak SwissTransfer - 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 InfomaniakCoreSwiftUI
import STResources
import SwiftUI

struct EditSettingsView: View {
let leftIconAsset: STResourcesImages?
let label: String
let action: () -> Void

var body: some View {
Button(action: action) {
if let leftIconAsset {
Image(asset: leftIconAsset)
.iconSize(.large)
}

Text(label)
.lineLimit(1)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.headline)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}

// #Preview {
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
// EditSettingsView(leftIconAsset: nil, label: "coucou")
// }
110 changes: 110 additions & 0 deletions SwissTransferFeatures/SettingsView/Cells/SettingsCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Infomaniak SwissTransfer - 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 InfomaniakCoreSwiftUI
import STResources
import SwiftUI

// TODO: Navigation link
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
struct SettingsCell: View {
let title: String
let subtitle: String
let leftIconAsset: STResourcesImages
let rightIconAsset: STResourcesImages?

init(title: String, subtitle: String, leftIconAsset: STResourcesImages, rightIconAsset: STResourcesImages? = nil) {
self.title = title
self.subtitle = subtitle
self.leftIconAsset = leftIconAsset
self.rightIconAsset = rightIconAsset
}

var body: some View {
HStack(spacing: IKPadding.small) {
Image(asset: leftIconAsset)
.iconSize(.large)

VStack(alignment: .leading) {
Text(title)
.lineLimit(1)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.headline)
Text(subtitle)
.lineLimit(1)
.foregroundStyle(Color.ST.textSecondary)
.font(.ST.callout)
}
.frame(maxWidth: .infinity, alignment: .leading)

if let rightIconAsset {
Image(asset: rightIconAsset)
.iconSize(.large)
}
}
}
}

struct SingleLabelSettingsCell: View {
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
let title: String
let rightIconAsset: STResourcesImages?

init(title: String, rightIconAsset: STResourcesImages? = nil) {
self.title = title
self.rightIconAsset = rightIconAsset
}

var body: some View {
HStack(spacing: IKPadding.small) {
Text(title)
.lineLimit(1)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.headline)
.frame(maxWidth: .infinity, alignment: .leading)

if let rightIconAsset {
Image(asset: rightIconAsset)
.iconSize(.large)
}
}
}
}

struct AboutSettingsCell: View {
let title: String
let subtitle: String

var body: some View {
HStack {
VStack(alignment: .leading) {
Text(title)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.headline)
Text(subtitle)
.foregroundStyle(Color.ST.textSecondary)
.font(.ST.callout)
}
}
}
}

#Preview {
SettingsCell(title: "coucou",
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
subtitle: "coucou",
leftIconAsset: STResourcesAsset.Images.clock,
rightIconAsset: STResourcesAsset.Images.clock)
}
Loading
Loading