ios: fix chat list bottom bar background appearance (#4612)

* ios: fix chat list bottom bar background appearance

* push up bottom bar, when no home indicator is present; tapable chats

* smaller toolbar

---------

Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Arturs Krumins
2024-08-07 18:24:15 +03:00
committed by GitHub
parent 1a6245fe51
commit 239c815f3e

View File

@@ -88,13 +88,25 @@ struct ChatListView: View {
.safeAreaInset(edge: .top) {
if oneHandUI { Divider().background(Material.ultraThin) }
}
.safeAreaInset(edge: .bottom) {
if oneHandUI {
Divider().padding(.bottom, Self.hasHomeIndicator ? 0 : 8).background(Material.ultraThin)
}
}
}
static var hasHomeIndicator: Bool = {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first {
window.safeAreaInsets.bottom > 0
} else { false }
}()
@ViewBuilder func withToolbar(content: () -> some View) -> some View {
if #available(iOS 16.0, *) {
if oneHandUI {
content()
.toolbarBackground(.visible, for: .bottomBar)
.toolbarBackground(.hidden, for: .bottomBar)
.toolbar { bottomToolbar }
} else {
content()
@@ -112,28 +124,18 @@ struct ChatListView: View {
@ToolbarContentBuilder var topToolbar: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) { leadingToolbarItem }
ToolbarItem(placement: .principal) { principalToolbarItem }
ToolbarItem(placement: .principal) { SubsStatusIndicator() }
ToolbarItem(placement: .topBarTrailing) { trailingToolbarItem }
}
@ToolbarContentBuilder var bottomToolbar: some ToolbarContent {
ToolbarItem(placement: .bottomBar) {
let v = HStack {
leadingToolbarItem
principalToolbarItem
trailingToolbarItem
}
if #available(iOS 16.0, *) {
v
} else {
VStack(spacing: 0) {
Divider()
v
.padding(.vertical)
.frame(maxWidth: .infinity)
.background(Material.ultraThin)
}
}
let padding: Double = Self.hasHomeIndicator ? 0 : 14
ToolbarItemGroup(placement: .bottomBar) {
leadingToolbarItem.padding(.bottom, padding)
Spacer()
SubsStatusIndicator().padding(.bottom, padding)
Spacer()
trailingToolbarItem.padding(.bottom, padding)
}
}
@@ -160,14 +162,6 @@ struct ChatListView: View {
}
}
@ViewBuilder var principalToolbarItem: some View {
HStack(spacing: 4) {
Text("Chats").font(.headline)
SubsStatusIndicator()
}
.frame(maxWidth: .infinity, alignment: .center)
}
@ViewBuilder var trailingToolbarItem: some View {
switch chatModel.chatRunning {
case .some(true): NewChatMenuButton()
@@ -313,6 +307,7 @@ struct SubsStatusIndicator: View {
showServersSummary = true
} label: {
HStack(spacing: 4) {
Text("Chats").foregroundStyle(Color.primary).fixedSize().font(.headline)
SubscriptionStatusIndicatorView(subs: subs, hasSess: hasSess)
if showSubscriptionPercentage {
SubscriptionStatusPercentageView(subs: subs, hasSess: hasSess)