Skip to content
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

Add Custom themes via XML for light / dark mode #507

Merged
merged 4 commits into from
Nov 21, 2017

Conversation

danesfeder
Copy link
Contributor

Will allows developers to add a light and dark theme via the NavigationView XML:

<com.mapbox.services.android.navigation.ui.v5.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:navigationLightTheme="@style/NavigationViewLight"
        app:navigationDarkTheme="@style/NavigationViewDark"
        ...
        />

This also adds the map style URLs to the themes.

cc @ericrwolfe

@danesfeder danesfeder added feature New feature request. ⚠️ DO NOT MERGE PR should not be merged! labels Nov 15, 2017
@danesfeder danesfeder self-assigned this Nov 15, 2017
@danesfeder danesfeder added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Nov 16, 2017
String nightThemeUrl = context.getString(R.string.navigation_guidance_night_v2);
String dayThemeUrl = context.getString(R.string.navigation_guidance_day_v2);
map.setStyleUrl(darkThemeEnabled ? nightThemeUrl : dayThemeUrl, listener);
TypedValue mapStyleAttr = new TypedValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we extract this block of code into a shared method in order to avoid duplication?

👀 methods retrieveNavigationViewPrimaryColor, retrieveNavigationViewSecondaryColor, retrieveNavigationViewBannerBackgroundColor, retrieveNavigationViewBannerManeuverPrimaryColor, retrieveNavigationViewBannerManeuverSecondaryColor, retrieveNavigationViewProgressColor and retrieveNavigationViewProgressBackgroundColor

*/
static void setTheme(Context context) {
static void setTheme(Context context, AttributeSet attrs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTheme method is getting long.

@danesfeder
Copy link
Contributor Author

@Guardiola31337 Addressed your comments, ready for another round 👀

@danesfeder danesfeder merged commit bcb95b9 into master Nov 21, 2017
@danesfeder danesfeder deleted the dan-nav-view-theme branch November 21, 2017 19:39
@danesfeder danesfeder mentioned this pull request Dec 6, 2017
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants