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 0972af30cf
commit 44062adb0f
8 changed files with 21 additions and 37 deletions
@@ -16,32 +16,23 @@
import SwiftUI import SwiftUI
/// Style for form section headers extension View {
struct FormSectionHeaderStyle: ViewModifier { /// Applies a standard style to forms.
func body(content: Content) -> some View { func elementFormStyle() -> some View {
content scrollContentBackground(.hidden)
.foregroundColor(.element.secondaryContent) .background(Color.element.formBackground.ignoresSafeArea())
}
/// Applies a standard style for form header text.
func formSectionHeader() -> some View {
foregroundColor(.element.secondaryContent)
.font(.compound.bodyXS) .font(.compound.bodyXS)
} }
}
/// Applies a standard style for form sections.
/// Standard style for form sections func formSectionStyle() -> some View {
struct FormSectionStyle: ViewModifier { listRowSeparator(.hidden)
func body(content: Content) -> some View {
content
.listRowSeparator(.hidden)
.listRowInsets(FormRow.insets) .listRowInsets(FormRow.insets)
.listRowBackground(Color.element.formRowBackground) .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())
}
}
@@ -28,8 +28,7 @@ struct CreateRoomScreen: View {
var body: some View { var body: some View {
mainContent mainContent
.scrollDismissesKeyboard(.immediately) .scrollDismissesKeyboard(.immediately)
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.navigationTitle(L10n.screenCreateRoomTitle) .navigationTitle(L10n.screenCreateRoomTitle)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
@@ -85,8 +85,7 @@ struct DeveloperOptionsScreen: View {
} }
} }
.overlay(effectsView) .overlay(effectsView)
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.navigationTitle(L10n.commonDeveloperOptions) .navigationTitle(L10n.commonDeveloperOptions)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
} }
@@ -22,8 +22,7 @@ struct InviteUsersScreen: View {
var body: some View { var body: some View {
mainContent mainContent
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.navigationTitle(L10n.screenCreateRoomActionInvitePeople) .navigationTitle(L10n.screenCreateRoomActionInvitePeople)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
@@ -27,8 +27,7 @@ struct RoomDetailsEditScreen: View {
var body: some View { var body: some View {
mainContent mainContent
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.scrollDismissesKeyboard(.immediately) .scrollDismissesKeyboard(.immediately)
.navigationTitle(L10n.screenRoomDetailsEditRoomTitle) .navigationTitle(L10n.screenRoomDetailsEditRoomTitle)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
@@ -41,8 +41,7 @@ struct RoomDetailsScreen: View {
leaveRoomSection leaveRoomSection
} }
} }
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.alert(item: $context.alertInfo) { $0.alert } .alert(item: $context.alertInfo) { $0.alert }
.alert(item: $context.leaveRoomAlertItem, .alert(item: $context.leaveRoomAlertItem,
actions: leaveRoomAlertActions, actions: leaveRoomAlertActions,
@@ -27,8 +27,7 @@ struct RoomMemberDetailsScreen: View {
blockUserSection blockUserSection
} }
} }
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.alert(item: $context.ignoreUserAlert, actions: blockUserAlertActions, message: blockUserAlertMessage) .alert(item: $context.ignoreUserAlert, actions: blockUserAlertActions, message: blockUserAlertMessage)
.errorAlert(item: $context.errorAlert) .errorAlert(item: $context.errorAlert)
} }
@@ -28,8 +28,7 @@ struct StartChatScreen: View {
searchContent searchContent
} }
} }
.scrollContentBackground(.hidden) .elementFormStyle()
.background(Color.element.formBackground.ignoresSafeArea())
.navigationTitle(L10n.actionStartChat) .navigationTitle(L10n.actionStartChat)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {