Improve search view.
This commit is contained in:
parent
2d2d1dfe0c
commit
20fafc4da8
|
@ -1137,7 +1137,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 53;
|
||||
CURRENT_PROJECT_VERSION = 54;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
@ -1174,7 +1174,7 @@
|
|||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 53;
|
||||
CURRENT_PROJECT_VERSION = 54;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
|
@ -93,8 +93,7 @@ struct MainView: View {
|
|||
ToolbarItem(placement: .principal) {
|
||||
Menu {
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .home
|
||||
self.switchView(to: .home)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .home))
|
||||
|
@ -103,8 +102,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .local
|
||||
self.switchView(to: .local)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .local))
|
||||
|
@ -113,8 +111,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .federated
|
||||
self.switchView(to: .federated)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .federated))
|
||||
|
@ -123,8 +120,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .search
|
||||
self.switchView(to: .search)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .search))
|
||||
|
@ -136,8 +132,7 @@ struct MainView: View {
|
|||
|
||||
Menu {
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .trendingPhotos
|
||||
self.switchView(to: .trendingPhotos)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .trendingPhotos))
|
||||
|
@ -146,8 +141,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .trendingTags
|
||||
self.switchView(to: .trendingTags)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .trendingTags))
|
||||
|
@ -156,8 +150,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .trendingAccounts
|
||||
self.switchView(to: .trendingAccounts)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .trendingAccounts))
|
||||
|
@ -174,8 +167,7 @@ struct MainView: View {
|
|||
Divider()
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .profile
|
||||
self.switchView(to: .profile)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .profile))
|
||||
|
@ -184,8 +176,7 @@ struct MainView: View {
|
|||
}
|
||||
|
||||
Button {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
viewMode = .notifications
|
||||
self.switchView(to: .notifications)
|
||||
} label: {
|
||||
HStack {
|
||||
Text(self.getViewTitle(viewMode: .notifications))
|
||||
|
@ -293,6 +284,19 @@ struct MainView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func switchView(to newViewMode: ViewMode) {
|
||||
HapticService.shared.fireHaptic(of: .tabSelection)
|
||||
|
||||
if viewMode == .search {
|
||||
hideKeyboard()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
self.viewMode = newViewMode
|
||||
}
|
||||
} else {
|
||||
self.viewMode = newViewMode
|
||||
}
|
||||
}
|
||||
|
||||
private func tryToSwitch(_ account: AccountData) {
|
||||
Task {
|
||||
// Verify access token correctness.
|
||||
|
|
|
@ -22,13 +22,13 @@ struct SearchView: View {
|
|||
HStack {
|
||||
TextField("Search...", text: $query)
|
||||
.padding(8)
|
||||
// .focused($focusedField, equals: .search)
|
||||
.focused($focusedField, equals: .search)
|
||||
.keyboardType(.default)
|
||||
.autocapitalization(.none)
|
||||
.autocorrectionDisabled()
|
||||
// .onAppear() {
|
||||
// self.focusedField = .search
|
||||
// }
|
||||
.onAppear() {
|
||||
self.focusedField = .search
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
|
@ -41,9 +41,6 @@ struct SearchView: View {
|
|||
.buttonStyle(.bordered)
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
self.focusedField = .unknown
|
||||
}
|
||||
|
||||
if self.query.isEmpty == false {
|
||||
Section {
|
||||
|
@ -66,6 +63,10 @@ struct SearchView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
self.focusedField = .unknown
|
||||
hideKeyboard()
|
||||
}
|
||||
.navigationTitle("Search")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue