From b7a339abf4280382932422abae0d08be2d5cf9cc Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 29 Aug 2024 08:40:31 -0700 Subject: [PATCH] Mock up text effect keyboard toolbar --- Localizable.xcstrings | 3 - .../TextMessageField/AlertButton.swift | 7 +- .../RequestPositionButton.swift | 5 +- .../TextMessageField/TextMessageField.swift | 90 ++++++++++++++----- .../TextMessageField/TextMessageSize.swift | 6 +- 5 files changed, 76 insertions(+), 35 deletions(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index cf5fc247e..b17372d3d 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -691,9 +691,6 @@ }, "Airtime %@%%" : { - }, - "Alert" : { - }, "Alert GPIO buzzer when receiving a bell" : { diff --git a/Meshtastic/Views/Messages/TextMessageField/AlertButton.swift b/Meshtastic/Views/Messages/TextMessageField/AlertButton.swift index 84820bef6..93b3d8ca4 100644 --- a/Meshtastic/Views/Messages/TextMessageField/AlertButton.swift +++ b/Meshtastic/Views/Messages/TextMessageField/AlertButton.swift @@ -5,11 +5,8 @@ struct AlertButton: View { var body: some View { Button(action: action) { - Text("Alert") - Image(systemName: "bell.fill") - .symbolRenderingMode(.hierarchical) - .imageScale(.large) - .foregroundColor(.accentColor) + Image(systemName: "bell.and.waves.left.and.right") + .foregroundColor(.primary) } } } diff --git a/Meshtastic/Views/Messages/TextMessageField/RequestPositionButton.swift b/Meshtastic/Views/Messages/TextMessageField/RequestPositionButton.swift index 2f1634bc2..f4ce0826f 100644 --- a/Meshtastic/Views/Messages/TextMessageField/RequestPositionButton.swift +++ b/Meshtastic/Views/Messages/TextMessageField/RequestPositionButton.swift @@ -6,11 +6,8 @@ struct RequestPositionButton: View { var body: some View { Button(action: action) { Image(systemName: "mappin.and.ellipse") - .symbolRenderingMode(.hierarchical) - .imageScale(.large) - .foregroundColor(.accentColor) + .foregroundColor(.primary) } - .padding(.trailing) } } diff --git a/Meshtastic/Views/Messages/TextMessageField/TextMessageField.swift b/Meshtastic/Views/Messages/TextMessageField/TextMessageField.swift index 469e57a41..ca2a8428a 100644 --- a/Meshtastic/Views/Messages/TextMessageField/TextMessageField.swift +++ b/Meshtastic/Views/Messages/TextMessageField/TextMessageField.swift @@ -13,9 +13,10 @@ struct TextMessageField: View { @State private var typingMessage: String = "" @State private var totalBytes = 0 @State private var sendPositionWithMessage = false + @State private var textEffects = false var body: some View { - #if targetEnvironment(macCatalyst) +#if targetEnvironment(macCatalyst) HStack { if destination.showAlertButton { Spacer() @@ -25,7 +26,7 @@ struct TextMessageField: View { RequestPositionButton(action: requestPosition) TextMessageSize(maxbytes: Self.maxbytes, totalBytes: totalBytes).padding(.trailing) } - #endif +#endif HStack(alignment: .top) { ZStack { @@ -40,19 +41,70 @@ struct TextMessageField: View { .keyboardType(.default) .toolbar { ToolbarItemGroup(placement: .keyboard) { - Button("dismiss.keyboard") { - isFocused = false - } - .font(.subheadline) - - if destination.showAlertButton { + if !textEffects { + VStack { + HStack { + TextMessageSize(maxbytes: Self.maxbytes, totalBytes: totalBytes) + Spacer() + if destination.showAlertButton { + AlertButton { typingMessage += "🔔 Alert Bell Character! \u{7}" } + Spacer() + } + RequestPositionButton(action: requestPosition) + Spacer() + Button { + textEffects = true + } + label: { + Image(systemName: "bold.italic.underline") + .foregroundColor(.primary) + } + Spacer() + Spacer() + Button { + isFocused = false + } + label: { + Image(systemName: "keyboard.chevron.compact.down") + .foregroundColor(.primary) + } + } + } + } else { + Spacer() + Button { + textEffects = false + } + label: { + Image(systemName: "bold") + .foregroundColor(.primary) + } + Spacer() + Button { + textEffects = false + } + label: { + Image(systemName: "italic") + .foregroundColor(.primary) + } + Spacer() + Button { + textEffects = false + } + label: { + Image(systemName: "underline") + .foregroundColor(.primary) + } + Spacer() + Button { + textEffects = false + } + label: { + Image(systemName: "strikethrough") + .foregroundColor(.primary) + } Spacer() - AlertButton { typingMessage += "🔔 Alert Bell Character! \u{7}" } } - - Spacer() - RequestPositionButton(action: requestPosition) - TextMessageSize(maxbytes: Self.maxbytes, totalBytes: totalBytes) } } .padding(.horizontal, 8) @@ -61,18 +113,16 @@ struct TextMessageField: View { .frame(minHeight: 50) .keyboardShortcut(.defaultAction) .onSubmit { - #if targetEnvironment(macCatalyst) +#if targetEnvironment(macCatalyst) sendMessage() - #endif +#endif } - Text(typingMessage) .opacity(0) .padding(.all, 0) } .overlay(RoundedRectangle(cornerRadius: 20).stroke(.tertiary, lineWidth: 1)) .padding(.bottom, 15) - Button(action: sendMessage) { Image(systemName: "arrow.up.circle.fill") .font(.largeTitle) @@ -122,21 +172,21 @@ private extension MessageDestination { case .channel: return "has shared their position with you" } } - + var positionDestNum: Int64 { switch self { case let .user(user): return user.num case .channel: return Int64(Constants.maximumNodeNum) } } - + var showAlertButton: Bool { switch self { case .user: return true case .channel: return true } } - + var wantPositionResponse: Bool { switch self { case .user: return true diff --git a/Meshtastic/Views/Messages/TextMessageField/TextMessageSize.swift b/Meshtastic/Views/Messages/TextMessageField/TextMessageSize.swift index 2b7b1e5e8..c6f222420 100644 --- a/Meshtastic/Views/Messages/TextMessageField/TextMessageSize.swift +++ b/Meshtastic/Views/Messages/TextMessageField/TextMessageSize.swift @@ -6,9 +6,9 @@ struct TextMessageSize: View { var body: some View { ProgressView("\("bytes".localized): \(totalBytes) / \(maxbytes)", value: Double(totalBytes), total: Double(maxbytes)) - .frame(width: 130) - .padding(5) - .font(.subheadline) + .frame(width: 120) + .font(.caption) + .fixedSize() .accentColor(.accentColor) } }