-
Notifications
You must be signed in to change notification settings - Fork 86
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
Supporting Material Library #124
base: master
Are you sure you want to change the base?
Conversation
…ndroid app module
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.
Hi @Zoha131, thank you for your contribution and sorry it took me a while to review it. I think you're on the right path here but I've got some comments. I think this can be simplified in a number of ways. If you can work on it some more I can take a closer look and try to see how to best address the textAppearance
issue.
@@ -0,0 +1,119 @@ | |||
<component name="ProjectCodeStyleConfiguration"> |
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.
Please don't commit this file.
@@ -19,6 +19,7 @@ rootProject.ext { | |||
MOCKITO_VERSION = '2.23.0' | |||
ROBOLECTRIC_VERSION = '3.8' | |||
TESTING_COMPILE_VERSION = '0.15' | |||
MATERIAL_VERSION = '1.1.0-rc01' |
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.
Could we use a stable version instead?
|
||
private var mColors: ColorStateList? = null | ||
private val defaultTextAppearance:Int = 16974317 //todo this might not be the default for every android version or phone | ||
private var mTextAppearance = defaultTextAppearance |
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.
This project doesn't follow the m
prefix convention. You can call these colors
and textAppearance
.
} | ||
|
||
@Attr(R2.styleable.Paris_MaterialButton_android_textColor) | ||
fun setTextColor(colors: ColorStateList?) { |
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.
MaterialButton
extends from TextView
so all the attributes supported by TextViewProxy
and ViewProxy
should already work. They don't need to be added again here.
/* | ||
* Material component has default textAppearance. | ||
* But if we do not pass any textAppearance then | ||
* android default textAppearance is set. To keep the |
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.
If the style doesn't define textAppearance
and the theme does then the theme value will be used. That's probably what you're observing and it is the correct behavior. I don't think we should be trying to override it here.
if(mColors == null){ | ||
val typedValue = TypedValue() | ||
view.context.theme.resolveAttribute(R.attr.colorOnPrimary, typedValue, true) | ||
view.setTextColor(typedValue.data) |
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.
How is using colorOnPrimary
implemented in MaterialButton
? This may be unnecessary.
|
||
object ViewUtils { | ||
|
||
fun parseTintMode(value: Int, defaultMode: PorterDuff.Mode): PorterDuff.Mode { |
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.
Reiterating a comment above: this is already implemented by ViewProxy
and is not needed here.
@@ -0,0 +1,27 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<resources> | |||
<declare-styleable name="Paris_MaterialButton"> |
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.
This should only include the XML attributes that are specifically owned by the MaterialButton
class (see https://developer.android.com/reference/com/google/android/material/button/MaterialButton), not its parents.
@@ -0,0 +1,25 @@ | |||
apply plugin: 'com.android.application' |
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.
I don't think we need a sample app specifically for material, you can use the existing sample app.
Adding MaterialButtonProxy to support dynamic style for MaterialButton.
As stated in the issue: #91 I am submitting this PR for review.
The problems I am facing:
For TextColor and TextAppearance when the user does not pass any value then by default it does not pick the material theme color
When I tried to add style using the style resource then I get some unexpected behavior. It does not work as intended.
Code Structure I have used: