Skip to content

Commit

Permalink
refactor(app): settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Dec 2, 2024
1 parent 8195d15 commit dc6dc04
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 71 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ private let appStoreUrl = URL(
string: "https://apps.apple.com/cz/app/metro-now/id6504659402?platform=iphone"
)

struct SettingsPageAboutSectionView: View {
let version = getFormattedVersionNumber()
struct SettingsAboutPageView: View {
private let formattedVersion = getFormattedVersionNumber()
private let application = UIApplication.shared
private let version = Bundle.main.versionNumber ?? ""
private let build = Bundle.main.buildNumber ?? ""

var body: some View {
Section(
header: Label("About", systemImage: "info.circle")
) {
List {
if let appStoreUrl {
ShareLink(item: appStoreUrl) {
Label(
Expand All @@ -35,7 +36,7 @@ struct SettingsPageAboutSectionView: View {

if let reportBugUrl = getGithubIssueUrl(
template: .bug_report,
title: "Bug in version \(version)"
title: "Bug in version \(formattedVersion)"
) {
Link(destination: reportBugUrl) {
Label(
Expand All @@ -57,12 +58,28 @@ struct SettingsPageAboutSectionView: View {
}
.accessibilityHint("Opens Github feature request form")
}

Section {
HStack{
Text("Version")
Spacer()
Text(version).fontDesign(.monospaced)
}
HStack{
Text("Build")
Spacer()
Text(String(build)).fontDesign(.monospaced)
}

if let sourceCodeUrl = URL(string: GITHUB_URL) {
Link("Source code", destination: sourceCodeUrl)
}
}
}
.navigationTitle("About")
}
}

#Preview {
List {
SettingsPageAboutSectionView()
}
SettingsAboutPageView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


// metro-now
// https://github.com/krystxf/metro-now

import SwiftUI

struct SettingsChangelogPageView: View {

var body: some View {
Text("Lorem ipsum")
.navigationTitle("What's new")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

// metro-now
// https://github.com/krystxf/metro-now

import SwiftUI

struct SettingsAppIconPageView: View {
private let application = UIApplication.shared


var body: some View {

List{
Section(header: Text("Choose your app icon")){
// if application.supportsAlternateIcons {
HStack{
Text("Prague metro")
}
.onTapGesture {
Task { @MainActor in
do {
try await application.setAlternateIconName("AppIconPragueMetro")
} catch {
print("error: \(error)")
}
}
}
// }
HStack{
Text("metro-now")
}
.onTapGesture {
Task { @MainActor in
do {
try await application.setAlternateIconName("AppIcon")
} catch {
print("error: \(error)")
}
}
}

}
}
.navigationTitle("App icon")

}
}


#Preview {
SettingsAppIconPageView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,40 @@
import SwiftUI

struct SettingsPageView: View {
@AppStorage(
AppStorageKeys.showMetroOnly.rawValue
) var showMetroOnly = false

var body: some View {
VStack {
List {
SettingsPageGeneralSectionView()
SettingsPageAboutSectionView()
}
Spacer()
SettingsPageFooterView()
}
.background(Color(UIColor.systemGroupedBackground))
List {
Section(header: Text("Customize")){
NavigationLink(
destination: SettingsAppIconPageView()
){
Label("App icon", systemImage: "app.dashed")
}
Toggle(isOn: $showMetroOnly) {
Text("Show only metro")
}
}



Section(header: Text("More")){
NavigationLink(
destination: SettingsChangelogPageView()
)
{
Label("What's new", systemImage: "sparkles")
}
NavigationLink(
destination: SettingsAboutPageView()
)
{
Label("About", systemImage: "info.square")
}
}
}
.navigationTitle("Settings")
}
}
Expand Down

0 comments on commit dc6dc04

Please sign in to comment.