0
0
mirror of https://git.743378673.xyz/MeloNX/MeloNX.git synced 2025-04-24 08:25:14 +00:00

Refactor navigation button labels and enhance SettingsView with app version display and keyboard dismissal functionality

This commit is contained in:
Bella 2025-04-13 21:24:35 +12:00 committed by Bella
parent 5c18cb1bbb
commit c6415d7e32
No known key found for this signature in database
GPG Key ID: 725FECA79EF56B97
3 changed files with 65 additions and 23 deletions

View File

@ -96,8 +96,8 @@ struct GameInfoSheet: View {
.navigationTitle(game.titleName)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") {
ToolbarItem(placement: .cancellationAction) {
Button("Dismiss") {
presentationMode.wrappedValue.dismiss()
}
}

View File

@ -239,26 +239,28 @@ struct GameLibraryView: View {
}
// Library Section
VStack(alignment: .leading) {
Text("Library")
.font(.headline)
.foregroundColor(.primary)
.padding(.horizontal)
.padding(.top)
ForEach(filteredGames) { game in
GameListRow(
game: game,
startemu: $startemu,
games: games,
isViewingGameInfo: $isViewingGameInfo,
isSelectingGameUpdate: $isSelectingGameUpdate,
isSelectingGameDLC: $isSelectingGameDLC,
gameRequirements: $gameRequirements,
gameInfo: $gameInfo
)
.padding(.horizontal, 3)
.padding(.vertical, 8)
if !filteredGames.isEmpty {
VStack(alignment: .leading) {
Text("Library")
.font(.headline)
.foregroundColor(.primary)
.padding(.horizontal)
.padding(.top)
ForEach(filteredGames) { game in
GameListRow(
game: game,
startemu: $startemu,
games: games,
isViewingGameInfo: $isViewingGameInfo,
isSelectingGameUpdate: $isSelectingGameUpdate,
isSelectingGameDLC: $isSelectingGameDLC,
gameRequirements: $gameRequirements,
gameInfo: $gameInfo
)
.padding(.horizontal, 3)
.padding(.vertical, 8)
}
}
}
} else {

View File

@ -93,6 +93,15 @@ struct SettingsView: View {
}
}
var appVersion: String {
guard let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
return "Unknown"
}
return version
}
@FocusState private var isArgumentsKeyboardVisible: Bool
var body: some View {
iOSNav {
ZStack {
@ -145,6 +154,7 @@ struct SettingsView: View {
}
.padding(.bottom)
}
.scrollDismissesKeyboardIfAvailable()
}
}
.navigationTitle("Settings")
@ -189,6 +199,14 @@ struct SettingsView: View {
Text("\(memoryText) RAM")
.font(.subheadline)
.foregroundColor(.secondary)
Text("·")
.font(.subheadline)
.foregroundColor(.secondary)
Text("Version \(appVersion)")
.font(.subheadline)
.foregroundColor(.secondary)
}
// Device cards
@ -747,7 +765,7 @@ struct SettingsView: View {
.foregroundColor(.primary)
if #available(iOS 15.0, *) {
TextField("Separate arguments with commas", text: Binding(
TextField("Separate arguments with commas" ,text: Binding(
get: {
config.additionalArgs.joined(separator: ", ")
},
@ -762,6 +780,14 @@ struct SettingsView: View {
.textInputAutocapitalization(.none)
.disableAutocorrection(true)
.padding(.vertical, 4)
.toolbar {
ToolbarItem(placement: .keyboard) {
Button("Dismiss") {
isArgumentsKeyboardVisible = false
}
}
}
.focused($isArgumentsKeyboardVisible)
} else {
TextField("Separate arguments with commas", text: Binding(
get: {
@ -1013,6 +1039,7 @@ struct CategoryButton: View {
RoundedRectangle(cornerRadius: 12)
.fill(isSelected ? Color.blue.opacity(0.15) : Color.clear)
)
.animation(.bouncy(duration: 0.3), value: isSelected)
}
}
}
@ -1122,3 +1149,16 @@ struct InfoCard: View {
.cornerRadius(8)
}
}
// this code is used to enable the keyboard to be dismissed when scrolling if available on iOS 16+
extension View {
@ViewBuilder
func scrollDismissesKeyboardIfAvailable() -> some View {
if #available(iOS 16.0, *) {
self.scrollDismissesKeyboard(.interactively)
} else {
self
}
}
}