mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Leave Room (#699)
* created the row in the view and the alert, and added the new function to the RoomProxy * fixed an issue with the alert function * handling the navigation * fixed a bug with the detail coordinators being dismissed incorrectly when inside a stack * implementation completed * replaced UI screenshots * added a test for the fixed bug of the coordinators * trying to increase the wait time for the expectation * improved the test * improved the buttons UI * uploading artifacts for unit tests * added result bundle true * improved the tests * added a new test * pr suggestions * updating mock * PR suggestions * improved tests * fixed UI tests * pr should be ready now * removed testing code * reduced complexity * fixed test * added a an assert to the new test case * more tests and messages cases * pr comments addressed * completed
This commit is contained in:
@@ -41,6 +41,7 @@ struct FormButtonStyle: PrimitiveButtonStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
Button(action: configuration.trigger) {
|
||||
configuration.label
|
||||
.labelStyle(FormRowLabelStyle(role: configuration.role))
|
||||
.frame(maxHeight: .infinity) // Make sure the label fills the cell vertically.
|
||||
}
|
||||
.buttonStyle(Style(accessory: accessory))
|
||||
@@ -54,7 +55,7 @@ struct FormButtonStyle: PrimitiveButtonStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack {
|
||||
configuration.label
|
||||
.labelStyle(FormRowLabelStyle())
|
||||
.labelStyle(FormRowLabelStyle(role: configuration.role))
|
||||
.foregroundColor(.element.primaryContent)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
@@ -104,6 +105,11 @@ struct FormButtonStyles_Previews: PreviewProvider {
|
||||
Label("Show something", systemImage: "rectangle.portrait")
|
||||
}
|
||||
.buttonStyle(FormButtonStyle(accessory: .navigationLink))
|
||||
|
||||
Button(role: .destructive) { } label: {
|
||||
Label("Show destruction", systemImage: "rectangle.portrait")
|
||||
}
|
||||
.buttonStyle(FormButtonStyle(accessory: .navigationLink))
|
||||
|
||||
ShareLink(item: "test")
|
||||
.buttonStyle(FormButtonStyle())
|
||||
@@ -117,6 +123,14 @@ struct FormButtonStyles_Previews: PreviewProvider {
|
||||
.buttonStyle(FormButtonStyle())
|
||||
}
|
||||
.formSectionStyle()
|
||||
|
||||
Section {
|
||||
Button(role: .destructive) { } label: {
|
||||
Label("Destroy", systemImage: "x.circle")
|
||||
}
|
||||
.buttonStyle(FormButtonStyle())
|
||||
}
|
||||
.formSectionStyle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,19 +19,44 @@ import SwiftUI
|
||||
struct FormRowLabelStyle: LabelStyle {
|
||||
@ScaledMetric private var menuIconSize = 30.0
|
||||
|
||||
var alignment: VerticalAlignment = .firstTextBaseline
|
||||
var alignment = VerticalAlignment.firstTextBaseline
|
||||
var role: ButtonRole?
|
||||
|
||||
private var titleColor: Color {
|
||||
if role == .destructive {
|
||||
return .element.alert
|
||||
} else {
|
||||
return .element.primaryContent
|
||||
}
|
||||
}
|
||||
|
||||
private var iconBackgroundColor: Color {
|
||||
if role == .destructive {
|
||||
return .element.alert.opacity(0.1)
|
||||
} else {
|
||||
return .element.formBackground
|
||||
}
|
||||
}
|
||||
|
||||
private var iconForegroundColor: Color {
|
||||
if role == .destructive {
|
||||
return .element.alert
|
||||
} else {
|
||||
return .element.secondaryContent
|
||||
}
|
||||
}
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(alignment: alignment, spacing: 16) {
|
||||
configuration.icon
|
||||
.foregroundColor(.element.secondaryContent)
|
||||
.foregroundColor(iconForegroundColor)
|
||||
.padding(4)
|
||||
.frame(width: menuIconSize, height: menuIconSize)
|
||||
.background(Color.element.formBackground)
|
||||
.background(iconBackgroundColor)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
configuration.title
|
||||
.font(.element.body)
|
||||
.foregroundColor(.element.primaryContent)
|
||||
.foregroundColor(titleColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +75,9 @@ struct FormRowLabelStyle_Previews: PreviewProvider {
|
||||
|
||||
Label("Help", systemImage: "questionmark")
|
||||
.labelStyle(FormRowLabelStyle())
|
||||
|
||||
Label("Destroy", systemImage: "x.circle")
|
||||
.labelStyle(FormRowLabelStyle(role: .destructive))
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user