From 33f6f3be0c93fb3027a2c82e481b277e790d1a19 Mon Sep 17 00:00:00 2001 From: Utsav Dave Date: Mon, 7 Jul 2025 23:24:55 -0400 Subject: [PATCH 1/2] fix for bug and leave alert --- bitchat/Views/ContentView.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 23e21ed8..792feeb2 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -26,6 +26,7 @@ struct ContentView: View { @State private var showPasswordError = false @State private var showCommandSuggestions = false @State private var commandSuggestions: [String] = [] + @State private var showLeaveChannelAlert = false private var backgroundColor: Color { colorScheme == .dark ? Color.black : Color.white @@ -289,13 +290,21 @@ struct ContentView: View { // Leave channel button Button(action: { - viewModel.leaveChannel(currentChannel) + showLeaveChannelAlert = true }) { Text("leave") .font(.system(size: 12, design: .monospaced)) .foregroundColor(Color.red) } .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 { // Public chat header @@ -617,6 +626,7 @@ struct ContentView: View { .textFieldStyle(.plain) .font(.system(size: 14, design: .monospaced)) .foregroundColor(textColor) + .autocorrectionDisabled() .focused($isTextFieldFocused) .onChange(of: messageText) { newValue in // Get cursor position (approximate - end of text for now) @@ -682,9 +692,10 @@ struct ContentView: View { Button(action: sendMessage) { Image(systemName: "arrow.up.circle.fill") .font(.system(size: 20)) - .foregroundColor((viewModel.selectedPrivateChatPeer != nil || - (viewModel.currentChannel != nil && viewModel.passwordProtectedChannels.contains(viewModel.currentChannel ?? ""))) - ? Color.orange : textColor) + .foregroundColor(messageText.isEmpty ? Color.gray : + (viewModel.selectedPrivateChatPeer != nil || + (viewModel.currentChannel != nil && viewModel.passwordProtectedChannels.contains(viewModel.currentChannel ?? ""))) + ? Color.orange : textColor) } .buttonStyle(.plain) .padding(.trailing, 12) From d3632b1c2a0828cfaa6075043649279394c0f225 Mon Sep 17 00:00:00 2001 From: Utsav Dave Date: Mon, 7 Jul 2025 23:41:36 -0400 Subject: [PATCH 2/2] added alert for other leave channel --- bitchat/Views/ContentView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 792feeb2..fb164053 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -819,7 +819,7 @@ struct ContentView: View { // Leave button Button(action: { - viewModel.leaveChannel(channel) + showLeaveChannelAlert = true }) { Text("leave channel") .font(.system(size: 10, design: .monospaced)) @@ -832,6 +832,14 @@ struct ContentView: View { ) } .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)?") + } } }