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

Updated hints to default behaviour #184

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions ControlRoom/Main Window/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct SidebarView: View {
}
.buttonStyle(.borderless)
.padding(.leading, 3)
.help("Show \(preferences.shouldShowOnlyActiveDevices ? "all" : "only active") devices")

SearchField("Filter", text: $filterText.onChange(controller.filterSimulators), onClear: {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,36 @@ struct NotificationEditorView: View {
HStack(spacing: 30) {
APSFormView(notificationAps: $notificationAps)

VStack(alignment: .leading) {
Text("Aps")
.font(.headline)
.addingInfoButton(title: "APS", description: "NotificationView.Hints.APS")

TextEditor(text: .constant(notificationAps.json))
.font(.system(.body, design: .monospaced))
.disableAutocorrection(true)
.frame(height: 200)
.scrollContentBackground(.hidden)
.padding(5)
.background(.quaternary)
.border(.tertiary, width: 1)

Text("User info")
.font(.headline)
.addingInfoButton(title: "User info", description: "NotificationView.Hints.UserInfo")

TextEditor(text: $userInfo)
.font(.system(.body, design: .monospaced))
.disableAutocorrection(true)
.frame(height: 200)
.scrollContentBackground(.hidden)
.padding(5)
.background(.quaternary)
.border(.tertiary, width: 1)
VStack(spacing: 16) {
VStack(alignment: .leading) {
Text("Aps")
.font(.headline)

TextEditor(text: .constant(notificationAps.json))
.font(.system(.body, design: .monospaced))
.disableAutocorrection(true)
.frame(height: 200)
.scrollContentBackground(.hidden)
.padding(5)
.background(.quaternary)
.border(.tertiary, width: 1)
}
.help("NotificationView.Hints.APS".localizedHint)

VStack(alignment: .leading) {
Text("User info")
.font(.headline)

TextEditor(text: $userInfo)
.font(.system(.body, design: .monospaced))
.disableAutocorrection(true)
.frame(height: 200)
.scrollContentBackground(.hidden)
.padding(5)
.background(.quaternary)
.border(.tertiary, width: 1)
}
.help("NotificationView.Hints.UserInfo".localizedHint)

Spacer()
}
Expand Down Expand Up @@ -255,10 +259,10 @@ private struct LocalizedFieldView: View {

HStack(spacing: 10) {
TextField("Localized key", text: $value)
.addingInfoButton(title: "Localized key", description: valueDescription)
.help(valueDescription.localizedHint)

TextField("Localized arguments", text: $arguments)
.addingInfoButton(title: "Localized key", description: argumentsDescription)
.help(argumentsDescription.localizedHint)
}
}
}
Expand All @@ -274,8 +278,8 @@ private struct FieldView: View {
Text(title)

TextField(title, text: $value)
.addingInfoButton(title: title, description: description)
}
.help(description.localizedHint)
}
}

Expand All @@ -285,10 +289,8 @@ private struct ToggleFieldView: View {
@Binding var value: Bool

var body: some View {
HStack {
Toggle(isOn: $value, label: { Text(title) })
}
.addingInfoButton(title: title, description: description)
Toggle(isOn: $value, label: { Text(title) })
.help(description.localizedHint)
}
}

Expand All @@ -313,42 +315,15 @@ private struct SliderFieldView: View {
Slider(value: $value, label: { Text(title) })
Text(sliderDisplayValue)
}
.help(description.localizedHint)
.disabled(!isEnabled)
.addingInfoButton(title: title, description: description)
}

var sliderDisplayValue: String {
Self.numberFormatter.string(for: value) ?? ""
}
}

private extension View {
func addingInfoButton(title: String, description: String) -> some View {
modifier(InfoButtonModifier(title: title,
description: description.localizedHint))
}
}

private struct InfoButtonModifier: ViewModifier {
let title: String
let description: String

@State private var shouldShowDescription = false

func body(content: Content) -> some View {
HStack {
content

Button("?") {
shouldShowDescription = true
}
}
.alert(isPresented: $shouldShowDescription) {
Alert(title: Text(title), message: Text(description))
}
}
}

private extension String {
var localizedHint: String {
NSLocalizedString(self, tableName: "NotificationEditorView", bundle: .main, comment: "")
Expand Down
Loading