This file contains hidden or 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
@Composable | |
fun DateInput(value: DateTime, onChange: (DateTime) -> Unit) { | |
ValidatedInput( | |
value, | |
onChange = { ... onChange(...) }, | |
isValid = isValidDate(value) | |
) | |
} |
This file contains hidden or 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
@Composable | |
fun DateRangeInput(value: DateRange, onChange: (DateRange) -> Unit) { | |
DateInput(value=value.start, ...) | |
DateInput(value=value.end, ...) | |
} |
This file contains hidden or 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
class FancyBox : View() { /* ... */ } | |
class Story : View() { /* ... */ } | |
class EditForm : FormView() { /* ... */ } | |
class FancyStory : ??? { /* ... */ } | |
class FancyEditForm : ??? { /* ... */ } |
This file contains hidden or 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
@Composable | |
fun FancyBox(children: @Composable () -> Unit) { | |
Box(fancy) { children() } | |
} | |
@Composable fun Story(…) { /* ... */ } | |
@Composable fun EditForm(...) { /* ... */ } | |
@Composable fun FancyStory(...) { | |
FancyBox { Story(…) } | |
} | |
@Composable fun FancyEditForm(...) { |
This file contains hidden or 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
@Composable | |
fun App(appData: AppData) { | |
val derivedData = compute(appData) | |
Header() | |
if (appData.isOwner) { | |
EditButton() | |
} | |
Body { | |
for (item in derivedData.items) { | |
Item(item) |
This file contains hidden or 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
fun Address( | |
$composer: Composer, | |
$static: Int, | |
number: Int, street: String, | |
city: String, state: String, zip: String | |
) { | |
Text($composer, ($static and 0b11) and (($static and 0b10) shr 1), "$number $street") | |
Text($composer, ($static and 0b100) shr 2, city) | |
Text($composer, 0b1, ", ") | |
Text($composer, ($static and 0b1000) shr 3, state) |
This file contains hidden or 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
fun bind(liveMsgs: LiveData<MessageData>) { | |
liveMsgs.observe(this) { msgs -> | |
updateBody(msgs) | |
} | |
} |
This file contains hidden or 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
@Composable | |
fun Messages(liveMsgs: LiveData<MessageData>) { | |
val msgs by liveMsgs.observeAsState() | |
for (msg in msgs) { | |
Message(msg) | |
} | |
} |
This file contains hidden or 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
// function declaration | |
suspend fun MyFun() { … } | |
// lambda declaration | |
val myLambda = suspend { … } | |
// function type | |
fun MyFun(myParam: suspend () -> Unit) { … } |
This file contains hidden or 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
// function declaration | |
@Composable fun MyFun() { … } | |
// lambda declaration | |
val myLambda = @Composable { … } | |
// function type | |
fun MyFun(myParam: @Composable () -> Unit) { … } |