mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-06 17:56:22 +00:00
customizable search position
This commit is contained in:
@@ -54,7 +54,6 @@ struct ChatListView: View {
|
||||
}
|
||||
}
|
||||
UserPicker(
|
||||
// showSettings: $showSettings,
|
||||
homeTab: Binding.constant(.chats),
|
||||
showConnectDesktop: $showConnectDesktop,
|
||||
userPickerVisible: $userPickerVisible
|
||||
|
||||
@@ -22,6 +22,8 @@ struct HomeView: View {
|
||||
@State private var searchShowingSimplexLink = false
|
||||
@State private var searchChatFilteredBySimplexLink: String? = nil
|
||||
|
||||
@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()
|
||||
@@ -46,12 +48,21 @@ struct HomeView: View {
|
||||
destination: chatView
|
||||
) {
|
||||
ZStack {
|
||||
switch homeTab {
|
||||
case .settings: settingsView()
|
||||
case .contacts: contactsView()
|
||||
case .chats: chatsView()
|
||||
case .newChat: newChatView()
|
||||
}
|
||||
switch homeTab {
|
||||
case .settings: settingsView()
|
||||
case .contacts: contactsView()
|
||||
case .chats:
|
||||
chatsView()
|
||||
.padding(.top, searchInBottom ? 10 : 40)
|
||||
case .newChat: newChatView()
|
||||
}
|
||||
|
||||
VStack {
|
||||
topToolbar()
|
||||
.background(BlurView(style: .systemMaterial).ignoresSafeArea())
|
||||
.frame(height: 40)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
VStack {
|
||||
Spacer()
|
||||
@@ -108,18 +119,20 @@ 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 homeTab == .chats {
|
||||
ChatsSearchBar(
|
||||
searchMode: $searchMode,
|
||||
searchFocussed: $searchFocussed,
|
||||
searchText: $searchText,
|
||||
searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 8)
|
||||
if searchInBottom, homeTab == .chats {
|
||||
chatsSearch()
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
@@ -142,6 +155,16 @@ struct HomeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func chatsSearch() -> some View {
|
||||
ChatsSearchBar(
|
||||
searchMode: $searchMode,
|
||||
searchFocussed: $searchFocussed,
|
||||
searchText: $searchText,
|
||||
searchShowingSimplexLink: $searchShowingSimplexLink,
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder private func settingsButton() -> some View {
|
||||
let user = chatModel.currentUser ?? User.sampleData
|
||||
let multiUser = chatModel.users.filter({ u in u.user.activeUser || !u.user.hidden }).count > 1
|
||||
|
||||
@@ -25,6 +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
|
||||
|
||||
var body: some View {
|
||||
VStack{
|
||||
@@ -39,6 +40,12 @@ struct AppearanceSettings: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section("Interface") {
|
||||
settingsRow("magnifyingglass") {
|
||||
Toggle("Search in bottom", isOn: $searchInBottom)
|
||||
}
|
||||
}
|
||||
|
||||
Section("App icon") {
|
||||
HStack {
|
||||
updateAppIcon(image: "icon-light", icon: nil, tapped: $iconLightTapped)
|
||||
|
||||
@@ -46,6 +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_CONNECT_VIA_LINK_TAB = "connectViaLinkTab"
|
||||
let DEFAULT_LIVE_MESSAGE_ALERT_SHOWN = "liveMessageAlertShown"
|
||||
let DEFAULT_SHOW_HIDDEN_PROFILES_NOTICE = "showHiddenProfilesNotice"
|
||||
@@ -89,6 +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_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