-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(design toolbox): display code implementation for each component #343
base: develop
Are you sure you want to change the base?
feat(design toolbox): display code implementation for each component #343
Conversation
🟢 Netlify deploy for commit ebbd895 succeededDeploy preview: https://67bc8471d957a627b9acc142--ouds-android.netlify.app |
752d732
to
ed5e392
Compare
|
||
private val CODE_INDENT = " " | ||
|
||
interface CodeFormattable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename it to FormattableCode
?
@DslMarker | ||
annotation class CodeDslMarker | ||
|
||
private val CODE_INDENT = " " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add const
as suggested by AS
|
||
fun Code.Builder.coloredBoxCall(onColoredBox: Boolean, content: Code.Builder.() -> Unit) { | ||
if (onColoredBox) { | ||
functionCall("OudsColoredBox") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we replace "OudsColoredBox" by OudsColoredBox.javaClass.simpleName
which seems safer if we rename it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, we can't use Composable methods references but I did not realize that we could use the associated object, that's a good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, this won't work with OudsCheckbox
because the associated object is internal
.
state = this@DemoScreen, | ||
modifier = Modifier | ||
.padding(all = OudsTheme.spaces.fixed.medium) | ||
.padding(top = OudsTheme.spaces.fixed.medium) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val text = stringResource(id = R.string.app_components_button_label) | ||
CodeSnippet(modifier = modifier) { | ||
coloredBoxCall(state.onColoredBox) { | ||
functionCall("OudsButton") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as before, should we use OudsButton.javaClass.simpleName
?
functionCall("OudsButton") { | ||
if (state.layout in listOf(ButtonDemoState.Layout.IconOnly, ButtonDemoState.Layout.IconAndText)) { | ||
constructorCallArgument<OudsButton.Icon>("icon") { | ||
functionCallArgument("painter", "painterResource") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we define constants for function names like painterResource
, stringResource`, ...?
state = this@DemoScreen, | ||
modifier = Modifier | ||
.padding(all = OudsTheme.spaces.fixed.medium) | ||
.padding(top = OudsTheme.spaces.fixed.medium) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, do we need this line?
|
||
override fun format(context: Context): String { | ||
val valueString = when (value) { | ||
is Float -> "${value}F" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float
is more represented with a lower case f
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought too. But if you write val a: Float = 1.0
, then Android Studio suggests to change this code to val a: Float = 1.0F
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the documentation seems to use f
: https://kotlinlang.org/docs/numbers.html#literal-constants-for-numbers
ed5e392
to
dfcb99b
Compare
dfcb99b
to
e058406
Compare
e058406
to
b1e7272
Compare
b1e7272
to
ebbd895
Compare
No description provided.