-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚙️ Add a new settings screen
- Loading branch information
Showing
11 changed files
with
211 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Constants.swift | ||
// AndroidTools | ||
// | ||
// Created by Thomas Bernard on 12/05/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
class Constants { | ||
static let appearanceModes : [String] = ["Automatic", "Dark", "Light"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
AndroidTools/AndroidTools/Presentation/Components/LargeButtonStyle.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
AndroidTools/AndroidTools/Presentation/Settings/AppearanceSettingsView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// AppearanceSettingsView.swift | ||
// AndroidTools | ||
// | ||
// Created by Thomas Bernard on 12/05/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AppearanceSettingsView: View { | ||
|
||
@AppStorage("mode") private var mode = Constants.appearanceModes.first! | ||
private let appIcons: [String] = ["AppIconDark", "AppIconLight", "AppIconAndroid"] | ||
@AppStorage("appIconName") private var appIconName = "AppIconDark" | ||
|
||
var body: some View { | ||
Form { | ||
Picker("Appearance", selection: $mode) { | ||
ForEach(Constants.appearanceModes, id: \.self) { mode in | ||
Text(mode) | ||
if mode == Constants.appearanceModes.first { | ||
Divider() | ||
} | ||
|
||
} | ||
} | ||
|
||
Text("Change application icon ") | ||
|
||
HStack { | ||
ForEach(appIcons, id: \.self) { name in | ||
VStack { | ||
Image(nsImage: NSImage(named: name)!) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: 60, height: 60) // Highlight the selected icon | ||
} | ||
|
||
.background(appIconName == name ? Color.accentColor : Color.clear) | ||
.cornerRadius(13) | ||
|
||
.onTapGesture { | ||
NSApplication.shared.applicationIconImage = NSImage(named: name) | ||
appIconName = name // Update the selected icon | ||
} | ||
} | ||
|
||
Spacer() | ||
} | ||
|
||
Spacer() | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
AppearanceSettingsView() | ||
} |
91 changes: 91 additions & 0 deletions
91
AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// ApplicationSettingsView.swift | ||
// AndroidTools | ||
// | ||
// Created by Thomas Bernard on 12/05/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ApplicationSettingsView: View { | ||
|
||
@StateObject private var viewModel = ApplicationSettingsViewModel() | ||
|
||
@AppStorage("adbPath") private var adbPath = "/usr/local/bin/adb" | ||
|
||
|
||
private func openFinderToSelectADB() { | ||
let panel = NSOpenPanel() | ||
panel.canChooseFiles = true | ||
panel.canChooseDirectories = false | ||
panel.allowsMultipleSelection = false | ||
panel.directoryURL = URL(fileURLWithPath: adbPath) | ||
|
||
panel.begin { response in | ||
if response == .OK, let url = panel.url { | ||
self.adbPath = url.path | ||
viewModel.getAdbVersion() | ||
} | ||
} | ||
} | ||
|
||
|
||
var body: some View { | ||
Form { | ||
VStack(alignment:.center) { | ||
HStack { | ||
if !viewModel.adbVersion.isEmpty { | ||
Image(systemName: "checkmark.circle.fill") | ||
.foregroundColor(.green) | ||
} | ||
else { | ||
Image(systemName: "xmark.circle.fill") | ||
.foregroundColor(.red) | ||
} | ||
|
||
Text("ADB version \(viewModel.adbVersion)") | ||
Spacer() | ||
Button("Check ADB version"){ | ||
viewModel.getAdbVersion() | ||
} | ||
} | ||
|
||
HStack { | ||
TextField("", text:$adbPath) | ||
.disabled(true) | ||
.padding(.leading, -10) | ||
|
||
Button("Change path"){ | ||
openFinderToSelectADB() | ||
} | ||
} | ||
|
||
|
||
|
||
Spacer() | ||
|
||
Divider() | ||
|
||
|
||
HStack { | ||
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" | ||
Text("Android Tools v\(appVersion)") | ||
|
||
Spacer() | ||
|
||
Button("Check for updates"){ | ||
viewModel.checkForUpdates() | ||
} | ||
} | ||
.padding(.top, 5) | ||
} | ||
} | ||
.onAppear { | ||
viewModel.getAdbVersion() | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
ApplicationSettingsView() | ||
} |
Oops, something went wrong.