mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-05 18:07:31 +00:00
rework wip
This commit is contained in:
@@ -12,19 +12,15 @@ import SimpleXChat
|
||||
struct ChatsView: View {
|
||||
@EnvironmentObject var chatModel: ChatModel
|
||||
|
||||
// @State private var searchMode = false
|
||||
// @FocusState private var searchFocussed
|
||||
// @State private var searchText = ""
|
||||
// @State private var searchShowingSimplexLink = false
|
||||
// @State private var searchChatFilteredBySimplexLink: String? = nil
|
||||
@Binding var searchText: String
|
||||
@Binding var searchShowingSimplexLink: Bool
|
||||
@Binding var searchChatFilteredBySimplexLink: String?
|
||||
@State private var searchMode = false
|
||||
@FocusState private var searchFocussed
|
||||
@State private var searchText = ""
|
||||
@State private var searchShowingSimplexLink = false
|
||||
@State private var searchChatFilteredBySimplexLink: String? = nil
|
||||
|
||||
@State private var newChatMenuOption: NewChatMenuOption? = nil // TODO remove?
|
||||
@AppStorage(DEFAULT_SHOW_UNREAD_AND_FAVORITES) private var showUnreadAndFavorites = false
|
||||
@AppStorage(DEFAULT_SEARCH_IN_BOTTOM) private var searchInBottom = false
|
||||
@AppStorage(DEFAULT_CHAT_LIST_REVERSED) private var chatListReversed = false
|
||||
@AppStorage(DEFAULT_ONE_HAND_UI) private var oneHandUI = true
|
||||
|
||||
var body: some View {
|
||||
if #available(iOS 16.0, *) {
|
||||
@@ -40,6 +36,7 @@ struct ChatsView: View {
|
||||
onboardingButtons()
|
||||
}
|
||||
chatsView
|
||||
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,38 +64,29 @@ struct ChatsView: View {
|
||||
}
|
||||
|
||||
@ViewBuilder private var chatList: some View {
|
||||
let cs = chatListReversed ? filteredChats().reversed() : filteredChats()
|
||||
let cs = filteredChats()
|
||||
ZStack {
|
||||
VStack {
|
||||
List {
|
||||
// if !chatModel.chats.isEmpty {
|
||||
// ChatsSearchBar(
|
||||
// searchMode: $searchMode,
|
||||
// searchFocussed: $searchFocussed,
|
||||
// searchText: $searchText,
|
||||
// searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
// searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
// )
|
||||
// .listRowSeparator(.hidden)
|
||||
// .frame(maxWidth: .infinity)
|
||||
// }
|
||||
|
||||
if !searchInBottom {
|
||||
Color.clear
|
||||
.listRowSeparator(.hidden)
|
||||
.frame(height: 40) // account for topToolbar height
|
||||
if !chatModel.chats.isEmpty {
|
||||
ChatsSearchBar(
|
||||
searchMode: $searchMode,
|
||||
searchFocussed: $searchFocussed,
|
||||
searchText: $searchText,
|
||||
searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
|
||||
.listRowSeparator(.hidden)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
ForEach(cs, id: \.viewId) { chat in
|
||||
ChatListNavLink(chat: chat)
|
||||
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
|
||||
.padding(.trailing, -16)
|
||||
.disabled(chatModel.chatRunning != true || chatModel.deletedChats.contains(chat.chatInfo.id))
|
||||
}
|
||||
.offset(x: -8)
|
||||
|
||||
Color.clear
|
||||
.listRowSeparator(.hidden)
|
||||
.frame(height: searchInBottom ? 80 : 40) // account for bottomToolbar height
|
||||
}
|
||||
}
|
||||
.onChange(of: chatModel.chatId) { _ in
|
||||
@@ -267,11 +255,6 @@ struct ChatsSearchBar: View {
|
||||
searchFocussed = false
|
||||
}
|
||||
} else if m.chats.count > 0 {
|
||||
// Text("Filter")
|
||||
// .foregroundColor(.accentColor)
|
||||
// .onTapGesture {
|
||||
// showUnreadAndFavorites = !showUnreadAndFavorites
|
||||
// }
|
||||
toggleFilterButton()
|
||||
}
|
||||
}
|
||||
@@ -373,18 +356,10 @@ struct ChatsView_Previews: PreviewProvider {
|
||||
|
||||
]
|
||||
return Group {
|
||||
ChatsView(
|
||||
searchText: Binding.constant(""),
|
||||
searchShowingSimplexLink: Binding.constant(false),
|
||||
searchChatFilteredBySimplexLink: Binding.constant(nil)
|
||||
)
|
||||
.environmentObject(chatModel)
|
||||
ChatsView(
|
||||
searchText: Binding.constant(""),
|
||||
searchShowingSimplexLink: Binding.constant(false),
|
||||
searchChatFilteredBySimplexLink: Binding.constant(nil)
|
||||
)
|
||||
.environmentObject(ChatModel())
|
||||
ChatsView()
|
||||
.environmentObject(chatModel)
|
||||
ChatsView()
|
||||
.environmentObject(ChatModel())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,27 +16,21 @@ struct HomeView: View {
|
||||
@State private var showConnectDesktop = false
|
||||
@State private var newChatMenuOption: NewChatMenuOption? = nil
|
||||
|
||||
@State private var searchMode = false
|
||||
@FocusState private var searchFocussed
|
||||
@State private var searchText = ""
|
||||
@State private var searchShowingSimplexLink = false
|
||||
@State private var searchChatFilteredBySimplexLink: String? = nil
|
||||
@AppStorage(DEFAULT_ONE_HAND_UI) private var oneHandUI = true
|
||||
|
||||
@AppStorage(DEFAULT_SEARCH_IN_BOTTOM) private var searchInBottom = false
|
||||
|
||||
// init(homeTab: Binding<HomeTab>) {
|
||||
// // Make the background color of the bottom toolbar fully transparent
|
||||
// let appearance = UIToolbarAppearance()
|
||||
// appearance.configureWithOpaqueBackground()
|
||||
// appearance.shadowColor = .clear
|
||||
// appearance.backgroundColor = .clear
|
||||
// appearance.backgroundImage = UIImage()
|
||||
// UIToolbar.appearance().standardAppearance = appearance
|
||||
// UIToolbar.appearance().compactAppearance = appearance
|
||||
// UIToolbar.appearance().scrollEdgeAppearance = appearance
|
||||
//
|
||||
// self._homeTab = homeTab
|
||||
// }
|
||||
// init(homeTab: Binding<HomeTab>) {
|
||||
// // Make the background color of the bottom toolbar fully transparent
|
||||
// let appearance = UIToolbarAppearance()
|
||||
// appearance.configureWithOpaqueBackground()
|
||||
// appearance.shadowColor = .clear
|
||||
// appearance.backgroundColor = .clear
|
||||
// appearance.backgroundImage = UIImage()
|
||||
// UIToolbar.appearance().standardAppearance = appearance
|
||||
// UIToolbar.appearance().compactAppearance = appearance
|
||||
// UIToolbar.appearance().scrollEdgeAppearance = appearance
|
||||
//
|
||||
// self._homeTab = homeTab
|
||||
// }
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottomLeading) {
|
||||
@@ -47,38 +41,34 @@ struct HomeView: View {
|
||||
),
|
||||
destination: chatView
|
||||
) {
|
||||
ZStack {
|
||||
// ZStack {
|
||||
VStack {
|
||||
switch homeTab {
|
||||
case .settings: settingsView()
|
||||
case .contacts: contactsView()
|
||||
case .chats: chatsView()
|
||||
case .newChat: newChatView()
|
||||
}
|
||||
|
||||
VStack {
|
||||
topToolbar()
|
||||
.background(BlurView(style: .systemThinMaterial).ignoresSafeArea())
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .bottomBar) {
|
||||
settingsButton()
|
||||
Spacer()
|
||||
}
|
||||
|
||||
VStack {
|
||||
contactsButton()
|
||||
Spacer()
|
||||
bottomToolbar()
|
||||
.background(BlurView(style: .systemThinMaterial).ignoresSafeArea())
|
||||
chatsButton()
|
||||
Spacer()
|
||||
newChatButton()
|
||||
}
|
||||
}
|
||||
|
||||
// .toolbar {
|
||||
// ToolbarItemGroup(placement: .bottomBar) {
|
||||
// settingsButton()
|
||||
// Spacer()
|
||||
// contactsButton()
|
||||
// Spacer()
|
||||
// chatsButton()
|
||||
// Spacer()
|
||||
// newChatButton()
|
||||
// }
|
||||
// VStack {
|
||||
// Spacer()
|
||||
// bottomToolbar()
|
||||
// .background(BlurView(style: .systemThinMaterial).ignoresSafeArea())
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// if homeTab == .chats {
|
||||
// VStack {
|
||||
// Spacer()
|
||||
@@ -95,7 +85,6 @@ struct HomeView: View {
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if userPickerVisible {
|
||||
@@ -116,50 +105,19 @@ struct HomeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func topToolbar() -> some View {
|
||||
if !searchInBottom, homeTab == .chats {
|
||||
chatsSearch()
|
||||
.padding(.horizontal)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
}
|
||||
|
||||
private func bottomToolbar() -> some View {
|
||||
VStack {
|
||||
if searchInBottom, homeTab == .chats {
|
||||
chatsSearch()
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
|
||||
HStack {
|
||||
settingsButton()
|
||||
Spacer()
|
||||
.frame(height: 8)
|
||||
|
||||
if !searchFocussed {
|
||||
HStack {
|
||||
settingsButton()
|
||||
Spacer()
|
||||
contactsButton()
|
||||
Spacer()
|
||||
chatsButton()
|
||||
Spacer()
|
||||
newChatButton()
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.horizontal)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
contactsButton()
|
||||
Spacer()
|
||||
chatsButton()
|
||||
Spacer()
|
||||
newChatButton()
|
||||
}
|
||||
}
|
||||
|
||||
private func chatsSearch() -> some View {
|
||||
ChatsSearchBar(
|
||||
searchMode: $searchMode,
|
||||
searchFocussed: $searchFocussed,
|
||||
searchText: $searchText,
|
||||
searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.horizontal)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
@ViewBuilder private func settingsButton() -> some View {
|
||||
@@ -268,15 +226,16 @@ struct HomeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func chatsView() -> some View {
|
||||
@ViewBuilder private func chatsView() -> some View {
|
||||
// TODO onboarding buttons (remove?)
|
||||
// TODO for reversed chat list start at bottom
|
||||
ChatsView(
|
||||
searchText: $searchText,
|
||||
searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
.padding(.top, 5)
|
||||
if oneHandUI {
|
||||
ChatsView()
|
||||
.padding(.vertical, 5)
|
||||
} else {
|
||||
ChatsView()
|
||||
.padding(.top, 5)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func newChatView() -> some View {
|
||||
|
||||
@@ -25,8 +25,7 @@ struct AppearanceSettings: View {
|
||||
@State private var userInterfaceStyle = getUserInterfaceStyleDefault()
|
||||
@State private var uiTintColor = getUIAccentColorDefault()
|
||||
@AppStorage(DEFAULT_PROFILE_IMAGE_CORNER_RADIUS) private var profileImageCornerRadius = defaultProfileImageCorner
|
||||
@AppStorage(DEFAULT_SEARCH_IN_BOTTOM) private var searchInBottom = false
|
||||
@AppStorage(DEFAULT_CHAT_LIST_REVERSED) private var chatListReversed = false
|
||||
@AppStorage(DEFAULT_ONE_HAND_UI) private var oneHandUI = true
|
||||
|
||||
var body: some View {
|
||||
VStack{
|
||||
@@ -42,11 +41,8 @@ struct AppearanceSettings: View {
|
||||
}
|
||||
|
||||
Section("Interface") {
|
||||
settingsRow("magnifyingglass") {
|
||||
Toggle("Search in bottom", isOn: $searchInBottom)
|
||||
}
|
||||
settingsRow("message") {
|
||||
Toggle("Reverse chat list", isOn: $chatListReversed)
|
||||
settingsRow("hand.tap") {
|
||||
Toggle("One-hand UI", isOn: $oneHandUI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ let DEFAULT_ACCENT_COLOR_GREEN = "accentColorGreen"
|
||||
let DEFAULT_ACCENT_COLOR_BLUE = "accentColorBlue"
|
||||
let DEFAULT_USER_INTERFACE_STYLE = "userInterfaceStyle"
|
||||
let DEFAULT_PROFILE_IMAGE_CORNER_RADIUS = "profileImageCornerRadius"
|
||||
let DEFAULT_SEARCH_IN_BOTTOM = "searchInBottom"
|
||||
let DEFAULT_CHAT_LIST_REVERSED = "chatListReversed"
|
||||
let DEFAULT_ONE_HAND_UI = "oneHandUI"
|
||||
let DEFAULT_CONNECT_VIA_LINK_TAB = "connectViaLinkTab"
|
||||
let DEFAULT_LIVE_MESSAGE_ALERT_SHOWN = "liveMessageAlertShown"
|
||||
let DEFAULT_SHOW_HIDDEN_PROFILES_NOTICE = "showHiddenProfilesNotice"
|
||||
@@ -91,8 +90,7 @@ let appDefaults: [String: Any] = [
|
||||
DEFAULT_ACCENT_COLOR_BLUE: 1.000,
|
||||
DEFAULT_USER_INTERFACE_STYLE: 0,
|
||||
DEFAULT_PROFILE_IMAGE_CORNER_RADIUS: defaultProfileImageCorner,
|
||||
DEFAULT_SEARCH_IN_BOTTOM: false,
|
||||
DEFAULT_CHAT_LIST_REVERSED: false,
|
||||
DEFAULT_ONE_HAND_UI: true,
|
||||
DEFAULT_CONNECT_VIA_LINK_TAB: ConnectViaLinkTab.scan.rawValue,
|
||||
DEFAULT_LIVE_MESSAGE_ALERT_SHOWN: false,
|
||||
DEFAULT_SHOW_HIDDEN_PROFILES_NOTICE: true,
|
||||
|
||||
Reference in New Issue
Block a user