mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 18:05:19 +00:00
Merge pull request #35 from utsavDave97/main
Fix for send message bug and other new features
This commit is contained in:
@@ -26,6 +26,7 @@ struct ContentView: View {
|
|||||||
@State private var showPasswordError = false
|
@State private var showPasswordError = false
|
||||||
@State private var showCommandSuggestions = false
|
@State private var showCommandSuggestions = false
|
||||||
@State private var commandSuggestions: [String] = []
|
@State private var commandSuggestions: [String] = []
|
||||||
|
@State private var showLeaveChannelAlert = false
|
||||||
|
|
||||||
private var backgroundColor: Color {
|
private var backgroundColor: Color {
|
||||||
colorScheme == .dark ? Color.black : Color.white
|
colorScheme == .dark ? Color.black : Color.white
|
||||||
@@ -289,13 +290,21 @@ struct ContentView: View {
|
|||||||
|
|
||||||
// Leave channel button
|
// Leave channel button
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.leaveChannel(currentChannel)
|
showLeaveChannelAlert = true
|
||||||
}) {
|
}) {
|
||||||
Text("leave")
|
Text("leave")
|
||||||
.font(.system(size: 12, design: .monospaced))
|
.font(.system(size: 12, design: .monospaced))
|
||||||
.foregroundColor(Color.red)
|
.foregroundColor(Color.red)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
|
.alert("Leave Channel", isPresented: $showLeaveChannelAlert) {
|
||||||
|
Button("Cancel", role: .cancel) { }
|
||||||
|
Button("Leave", role: .destructive) {
|
||||||
|
viewModel.leaveChannel(currentChannel)
|
||||||
|
}
|
||||||
|
} message: {
|
||||||
|
Text("Are you sure you want to leave \(currentChannel)?")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Public chat header
|
// Public chat header
|
||||||
@@ -637,6 +646,7 @@ struct ContentView: View {
|
|||||||
.textFieldStyle(.plain)
|
.textFieldStyle(.plain)
|
||||||
.font(.system(size: 14, design: .monospaced))
|
.font(.system(size: 14, design: .monospaced))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
|
.autocorrectionDisabled()
|
||||||
.focused($isTextFieldFocused)
|
.focused($isTextFieldFocused)
|
||||||
.onChange(of: messageText) { newValue in
|
.onChange(of: messageText) { newValue in
|
||||||
// Get cursor position (approximate - end of text for now)
|
// Get cursor position (approximate - end of text for now)
|
||||||
@@ -702,9 +712,10 @@ struct ContentView: View {
|
|||||||
Button(action: sendMessage) {
|
Button(action: sendMessage) {
|
||||||
Image(systemName: "arrow.up.circle.fill")
|
Image(systemName: "arrow.up.circle.fill")
|
||||||
.font(.system(size: 20))
|
.font(.system(size: 20))
|
||||||
.foregroundColor((viewModel.selectedPrivateChatPeer != nil ||
|
.foregroundColor(messageText.isEmpty ? Color.gray :
|
||||||
(viewModel.currentChannel != nil && viewModel.passwordProtectedChannels.contains(viewModel.currentChannel ?? "")))
|
(viewModel.selectedPrivateChatPeer != nil ||
|
||||||
? Color.orange : textColor)
|
(viewModel.currentChannel != nil && viewModel.passwordProtectedChannels.contains(viewModel.currentChannel ?? "")))
|
||||||
|
? Color.orange : textColor)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.padding(.trailing, 12)
|
.padding(.trailing, 12)
|
||||||
@@ -828,7 +839,7 @@ struct ContentView: View {
|
|||||||
|
|
||||||
// Leave button
|
// Leave button
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.leaveChannel(channel)
|
showLeaveChannelAlert = true
|
||||||
}) {
|
}) {
|
||||||
Text("leave channel")
|
Text("leave channel")
|
||||||
.font(.system(size: 10, design: .monospaced))
|
.font(.system(size: 10, design: .monospaced))
|
||||||
@@ -841,6 +852,14 @@ struct ContentView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
|
.alert("Leave Channel", isPresented: $showLeaveChannelAlert) {
|
||||||
|
Button("Cancel", role: .cancel) { }
|
||||||
|
Button("Leave", role: .destructive) {
|
||||||
|
viewModel.leaveChannel(channel)
|
||||||
|
}
|
||||||
|
} message: {
|
||||||
|
Text("Are you sure you want to leave \(channel)?")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user