Backport base Form style from Compound. (#1009)

Apply to all screens using the formBackground colour.
This commit is contained in:
Doug
2023-06-02 11:39:03 +01:00
committed by GitHub
parent 16c5820ac8
commit 61f870def7
8 changed files with 21 additions and 37 deletions

View File

@@ -16,32 +16,23 @@
import SwiftUI
/// Style for form section headers
struct FormSectionHeaderStyle: ViewModifier {
func body(content: Content) -> some View {
content
.foregroundColor(.element.secondaryContent)
extension View {
/// Applies a standard style to forms.
func elementFormStyle() -> some View {
scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
}
/// Applies a standard style for form header text.
func formSectionHeader() -> some View {
foregroundColor(.element.secondaryContent)
.font(.compound.bodyXS)
}
}
/// Standard style for form sections
struct FormSectionStyle: ViewModifier {
func body(content: Content) -> some View {
content
.listRowSeparator(.hidden)
/// Applies a standard style for form sections.
func formSectionStyle() -> some View {
listRowSeparator(.hidden)
.listRowInsets(FormRow.insets)
.listRowBackground(Color.element.formRowBackground)
}
}
extension View {
/// Applies the `FormSectionHeaderStyle` modifier to the view
func formSectionHeader() -> some View {
modifier(FormSectionHeaderStyle())
}
func formSectionStyle() -> some View {
modifier(FormSectionStyle())
}
}

View File

@@ -28,8 +28,7 @@ struct CreateRoomScreen: View {
var body: some View {
mainContent
.scrollDismissesKeyboard(.immediately)
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.navigationTitle(L10n.screenCreateRoomTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {

View File

@@ -85,8 +85,7 @@ struct DeveloperOptionsScreen: View {
}
}
.overlay(effectsView)
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.navigationTitle(L10n.commonDeveloperOptions)
.navigationBarTitleDisplayMode(.inline)
}

View File

@@ -22,8 +22,7 @@ struct InviteUsersScreen: View {
var body: some View {
mainContent
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.navigationTitle(L10n.screenCreateRoomActionInvitePeople)
.navigationBarTitleDisplayMode(.inline)
.toolbar {

View File

@@ -27,8 +27,7 @@ struct RoomDetailsEditScreen: View {
var body: some View {
mainContent
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.scrollDismissesKeyboard(.immediately)
.navigationTitle(L10n.screenRoomDetailsEditRoomTitle)
.navigationBarTitleDisplayMode(.inline)

View File

@@ -41,8 +41,7 @@ struct RoomDetailsScreen: View {
leaveRoomSection
}
}
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.alert(item: $context.alertInfo) { $0.alert }
.alert(item: $context.leaveRoomAlertItem,
actions: leaveRoomAlertActions,

View File

@@ -27,8 +27,7 @@ struct RoomMemberDetailsScreen: View {
blockUserSection
}
}
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.alert(item: $context.ignoreUserAlert, actions: blockUserAlertActions, message: blockUserAlertMessage)
.errorAlert(item: $context.errorAlert)
}

View File

@@ -28,8 +28,7 @@ struct StartChatScreen: View {
searchContent
}
}
.scrollContentBackground(.hidden)
.background(Color.element.formBackground.ignoresSafeArea())
.elementFormStyle()
.navigationTitle(L10n.actionStartChat)
.navigationBarTitleDisplayMode(.inline)
.toolbar {