Factiorisation in ConfigurationView
@@ -10,14 +10,7 @@ struct ConfigurationView: MVIView {
VStack(spacing: 0) {
let fullMode = model is Configuration.ModelFullMode
- Section(
- header: Text("General")
- .bold()
- .font(.title3)
- .foregroundColor(.appHorizon)
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding()
- ) {
+ Section(header: headerText("General")) {
NavigationMenu(label: Text("About"), destination: AboutView())
NavigationMenu(label: Text("Display"), destination: DisplayConfigurationView())
NavigationMenu(label: Text("Electrum Server"), destination: ElectrumConfigurationView())
@@ -26,28 +19,14 @@ struct ConfigurationView: MVIView {
}
if fullMode {
- Section(
- header: Text("Security")
- .bold()
- .font(.title3)
- .foregroundColor(.appHorizon)
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding()
- ) {
+ Section(header: headerText("Security")) {
NavigationMenu(label: Text("Recovery phrase"), destination: EmptyView())
NavigationMenu(label: Text("App access settings"), destination: EmptyView())
Divider()
}
}
- Section(
- header: Text("Advanced")
- .bold()
- .font(.title3)
- .foregroundColor(.appHorizon)
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding()
- ) {
+ Section(header: headerText("Advanced")) {
NavigationMenu(label: Text("Logs"), destination: EmptyView())
if fullMode {
NavigationMenu(label: Text("Channels list"), destination: EmptyView())
@@ -66,6 +45,15 @@ struct ConfigurationView: MVIView {
}
}
+ func headerText(_ label: String) -> some View {
+ Text(label)
+ .bold()
+ .font(.title3)
+ .foregroundColor(.appHorizon)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding()
+ }
+
struct NavigationMenu<Parent, T: View> : View where Parent : View {
let label: Parent
let destination: T
