Skip to content

Commit

Permalink
chore: PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Nov 22, 2024
1 parent 2e0a730 commit 92ef4ae
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import SwiftUI

struct STNavigationBarStyleModifier: ViewModifier {
struct STNavigationTitleModifierStyleModifier: ViewModifier {
func body(content: Content) -> some View {
content
.navigationBarTitleDisplayMode(.inline)
Expand All @@ -31,6 +31,6 @@ struct STNavigationBarStyleModifier: ViewModifier {
public extension View {
/// Style the navigationBar
func stNavigationBarStyle() -> some View {
modifier(STNavigationBarStyleModifier())
modifier(STNavigationTitleModifierStyleModifier())
}
}
7 changes: 3 additions & 4 deletions SwissTransferCoreUI/Modifiers/STToolbar.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
/*
Infomaniak SwissTransfer - iOS App
Copyright (C) 2024 Infomaniak Network SA
Expand All @@ -19,7 +18,7 @@

import SwiftUI

public struct STNavigationBar: ViewModifier {
public struct STNavigationTitleModifier: ViewModifier {
public let title: String

public func body(content: Content) -> some View {
Expand All @@ -35,7 +34,7 @@ public struct STNavigationBar: ViewModifier {
}

public extension View {
func stNavigationBar(title: String) -> some View {
modifier(STNavigationBar(title: title))
func stNavigationTitle(_ title: String) -> some View {
modifier(STNavigationTitleModifier(title: title))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import SwiftUI

struct STNavigationBarNewTransferModifier: ViewModifier {
struct STNavigationTitleModifierNewTransferModifier: ViewModifier {
@Environment(\.dismissModal) private var dismissModal

let title: String
Expand All @@ -45,6 +45,6 @@ struct STNavigationBarNewTransferModifier: ViewModifier {

public extension View {
func stNavigationBarNewTransfer(title: String = "Transfer") -> some View {
modifier(STNavigationBarNewTransferModifier(title: title))
modifier(STNavigationTitleModifierNewTransferModifier(title: title))
}
}
16 changes: 7 additions & 9 deletions SwissTransferFeatures/SettingsView/Cells/AboutSettingsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ struct AboutSettingsCell: View {
let subtitle: String

var body: some View {
HStack {
VStack(alignment: .leading) {
Text(title)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.body)
Text(subtitle)
.foregroundStyle(Color.ST.textSecondary)
.font(.ST.callout)
}
VStack(alignment: .leading) {
Text(title)
.foregroundStyle(Color.ST.textPrimary)
.font(.ST.body)
Text(subtitle)
.foregroundStyle(Color.ST.textSecondary)
.font(.ST.callout)
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions SwissTransferFeatures/SettingsView/Cells/SettingsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct SettingsCell<Content: View>: View {
let title: String
let subtitle: String
var leftIconAsset: STResourcesImages?
var rightIconAsset: STResourcesImages?
@ViewBuilder var destination: () -> Content

var body: some View {
Expand All @@ -49,11 +48,6 @@ struct SettingsCell<Content: View>: View {
.font(.ST.callout)
}
.frame(maxWidth: .infinity, alignment: .leading)

if let rightIconAsset {
Image(asset: rightIconAsset)
.iconSize(.large)
}
}
}
}
Expand All @@ -62,6 +56,5 @@ struct SettingsCell<Content: View>: View {
#Preview {
SettingsCell(title: "Time",
subtitle: "Clock",
leftIconAsset: STResourcesAsset.Images.clock,
rightIconAsset: STResourcesAsset.Images.clock) {}
leftIconAsset: STResourcesAsset.Images.clock) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import InfomaniakCoreSwiftUI
import STResources
import SwiftUI

struct EditSettingsView: View {
struct EditSettingCell: View {
let selected: Bool
let label: String
var leftImage: Image?
Expand Down Expand Up @@ -51,7 +51,7 @@ struct EditSettingsView: View {
}

#Preview {
EditSettingsView(selected: true, label: "EditSettingsView") {
EditSettingCell(selected: true, label: "EditSettingsView", leftImage: nil) {
print("EditSettingsView action")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ struct EditSettingView<T: SettingSelectable>: View {
let section: String
let items: [T]
let selected: T
let onSelection: (T) async -> Void

public init(_ type: T.Type, selected: T, title: String, section: String, onSelection: @escaping (T) async -> Void) {
public init(_ type: T.Type, selected: T, title: String, section: String) {
items = Array(type.allCases)
self.selected = selected
self.title = title
self.section = section
self.onSelection = onSelection
}

var body: some View {
List(selection: $mainViewState.selectedDestination) {
Section(header: Text(section)) {
ForEach(items, id: \.self) { item in
EditSettingsView(selected: item == selected,
EditSettingCell(selected: item == selected,
label: item.title,

Check warning on line 46 in SwissTransferFeatures/SettingsView/EditSettings/EditSettingView.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Wrap lines that exceed the specified maximum width. (wrap)
leftImage: item.leftImage) {

Check warning on line 47 in SwissTransferFeatures/SettingsView/EditSettings/EditSettingView.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Wrap lines that exceed the specified maximum width. (wrap)
action(item)
Expand All @@ -53,18 +51,16 @@ struct EditSettingView<T: SettingSelectable>: View {
}
}
.stNavigationBarStyle()
.stNavigationBar(title: title)
.stNavigationTitle(title)
}

private func action(_ item: T) {
Task {
await onSelection(item)
await item.setSelected()
}
}
}

#Preview {
EditSettingView(Theme.self, selected: .dark, title: "Title", section: "Section") { theme in
print("selected \(theme)")
}
EditSettingView(Theme.self, selected: .dark, title: "Title", section: "Section")
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct NotificationsSettingsView: View {
expiredTransfers = newValue
}
.stNavigationBarStyle()
.stNavigationBar(title: STResourcesStrings.Localizable.settingsOptionNotifications)
.stNavigationTitle(STResourcesStrings.Localizable.settingsOptionNotifications)
}

private func computeAllNotificationsEnabled() -> Bool {
Expand Down
16 changes: 4 additions & 12 deletions SwissTransferFeatures/SettingsView/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public struct SettingsView: View {
EditSettingView(Theme.self,
selected: appSettings.value?.theme ?? .system,
title: STResourcesStrings.Localizable.settingsOptionTheme,
section: STResourcesStrings.Localizable.settingsThemeTitle) { theme in
await theme.setSelected()
}
section: STResourcesStrings.Localizable.settingsThemeTitle)
}

NotificationsSettingsCell {
Expand All @@ -70,9 +68,7 @@ public struct SettingsView: View {
EditSettingView(ValidityPeriod.self,
selected: appSettings.value?.validityPeriod ?? .thirty,
title: STResourcesStrings.Localizable.settingsOptionValidityPeriod,
section: STResourcesStrings.Localizable.settingsValidityPeriodTitle) { validity in
await validity.setSelected()
}
section: STResourcesStrings.Localizable.settingsValidityPeriodTitle)
}

SettingsCell(title: STResourcesStrings.Localizable.settingsOptionDownloadLimit,
Expand All @@ -81,9 +77,7 @@ public struct SettingsView: View {
EditSettingView(DownloadLimit.self,
selected: appSettings.value?.downloadLimit ?? .twoHundredFifty,
title: STResourcesStrings.Localizable.settingsOptionDownloadLimit,
section: STResourcesStrings.Localizable.settingsDownloadsLimitTitle) { downloadLimit in
await downloadLimit.setSelected()
}
section: STResourcesStrings.Localizable.settingsDownloadsLimitTitle)
}

SettingsCell(title: STResourcesStrings.Localizable.settingsOptionEmailLanguage,
Expand All @@ -92,9 +86,7 @@ public struct SettingsView: View {
EditSettingView(EmailLanguage.self,
selected: appSettings.value?.emailLanguage ?? .french,
title: STResourcesStrings.Localizable.settingsOptionEmailLanguage,
section: STResourcesStrings.Localizable.settingsEmailLanguageTitle) { emailLanguage in
await emailLanguage.setSelected()
}
section: STResourcesStrings.Localizable.settingsEmailLanguageTitle)
}
}

Expand Down

0 comments on commit 92ef4ae

Please sign in to comment.