Skip to content

Commit

Permalink
Mock up text effect keyboard toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
garthvh committed Aug 29, 2024
1 parent c678cd3 commit b7a339a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 35 deletions.
3 changes: 0 additions & 3 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,6 @@
},
"Airtime %@%%" : {

},
"Alert" : {

},
"Alert GPIO buzzer when receiving a bell" : {

Expand Down
7 changes: 2 additions & 5 deletions Meshtastic/Views/Messages/TextMessageField/AlertButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
90 changes: 70 additions & 20 deletions Meshtastic/Views/Messages/TextMessageField/TextMessageField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -25,7 +26,7 @@ struct TextMessageField: View {
RequestPositionButton(action: requestPosition)
TextMessageSize(maxbytes: Self.maxbytes, totalBytes: totalBytes).padding(.trailing)
}
#endif
#endif

HStack(alignment: .top) {
ZStack {
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit b7a339a

Please sign in to comment.