Created
June 21, 2019 13:00
-
-
Save drewmccormack/8202687caa133684d58a9db342e34564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is some SwiftUI code I have. | |
------ | |
NavigationView { | |
List(translations) { translation in | |
Button(action: { | |
self.dataSource.selectedTranslationId = translation.id | |
}) { | |
TranslationCell(translation: translation) | |
} | |
} | |
.navigationBarTitle(Text("Translations")) | |
.navigationBarItems( | |
leading: | |
Button(action: { | |
self.sceneDelegate?.signOut() | |
}, label: { Text("Sign Out") }), | |
trailing: | |
Group { | |
if dataSource.showingAdminInterface { | |
Button(action: { | |
self.sceneDelegate?.showImportView() | |
}, label: { | |
Image(systemName: "plus.circle.fill") | |
.imageScale(.large) | |
.foregroundColor(.green) | |
}) | |
} | |
} | |
) | |
} | |
.frame(minWidth: 300, idealWidth: 320) | |
I find it very difficult to read. Difficult to follow indentation. Difficult to see what modifiers apply, | |
because modifiers for children appear under the definition of the children. | |
Here is a stab at a data format that represents the same info in a more sane way: | |
NavigationView ( | |
[[ | |
frame: ( | |
minWidth: 300 | |
idealWidth: 320 | |
) | |
]] | |
views: [ | |
List ( | |
[[ | |
navigationBarTitle: [Text("Translations")] | |
navigationBarItems: ( | |
leading: [ | |
Button ( | |
action: { self.sceneDelegate?.signOut() } | |
label: [Text("Sign Out")] | |
) | |
] | |
trailing: [ | |
Group ( | |
if dataSource.showingAdminInterface { | |
Button ( | |
action: { self.sceneDelegate?.showImportView() } | |
label: [ | |
Image ( | |
[[ | |
imageScale: .large | |
foregroundColor: .green | |
]] | |
systemName: "plus.circle.fill" | |
) | |
] | |
) | |
} | |
) | |
] | |
) | |
]] | |
items: translations | |
views: [ translation in | |
Button ( | |
action: { | |
self.dataSource.selectedTranslationId = translation.id | |
} | |
views: [ | |
TranslationCell(translation: translation) | |
] | |
) | |
] | |
) | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment