Skip to content

Conversation

@Samo8
Copy link
Contributor

@Samo8 Samo8 commented Dec 19, 2025

Fixes #489

Implemented Parameters

backgroundColor - Dialog background color
titleColor - Title text color
mainTextColor - Main terms text color
acceptButtonTextColor - Accept button text color
cancelButtonTextColor - Cancel button text color

Not Implemented

Typography (Cross-platform)

More complex problem that can be handled in different PR
Title font (Android: setTitleTypeface(), iOS: titleFont)
Main text font (Android: setMainTextTypeface(), iOS: mainTextFont)
Button font (Android: setButtonsTypeface(), iOS: buttonsFont)

Text Sizes (Android only)

Android only can be handled in different PR
setTitleTextSize() - Title text size
setMainTextTextSize() - Main text size
setButtonsTextSize() - Button text size

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation
  • I added new tests to check the change I am making
  • All existing and new tests are passing.

@jokerttu jokerttu changed the title Feat/custom UI terms and conditions feat: custom UI terms and conditions Dec 22, 2025
Copy link
Contributor

@jokerttu jokerttu left a comment

Choose a reason for hiding this comment

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

The Android version wasn’t building. I added a few suggestions that should resolve the Android build issues.

Native Navigation SDK for Android seems to have internal bug with uiParams as the background color always leaks outside of the panel where dropshadow should be.

There is example implementation of this feature to example pages, camera, navigation_without_map and turn_by_turn.
If possible it would be nice to have this on navigation and navigation_without_map example pages only to keep the example pages simple and as those are main navigation related example pages. What do you think?

Please add a new integration test in https://github.com/googlemaps/flutter-navigation-sdk/blob/main/example/integration_test/t02_session_test.dart
that verifies uiParams. Because the integration tests run on both platforms (Android emulator and iOS simulator), this should also help detect potential crashes in the native implementations.

iOS Test:
Image

Android Test (after suggested fixes):
Image

)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

title: String,
companyName: String,
shouldOnlyShowDriverAwarenessDisclaimer: Boolean,
uiParams: Messages.TermsAndConditionsUIParamsDto?,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uiParams: Messages.TermsAndConditionsUIParamsDto?,
uiParams: TermsAndConditionsUIParamsDto?,

title: String,
companyName: String,
shouldOnlyShowDriverAwarenessDisclaimer: Boolean,
uiParams: Messages.TermsAndConditionsUIParamsDto?,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uiParams: Messages.TermsAndConditionsUIParamsDto?,
uiParams: TermsAndConditionsUIParamsDto?,

Comment on lines +552 to +568
// Build UI customization parameters if provided
val uiParams: TermsAndConditionsUIParams =
if (uiParams != null) {
val builder = TermsAndConditionsUIParams.builder()

// Apply custom colors if provided (convert from ARGB Long to Android Color Int)
uiParams.backgroundColor?.let { builder.setBackgroundColor(it.toInt()) }
uiParams.titleColor?.let { builder.setTitleColor(it.toInt()) }
uiParams.mainTextColor?.let { builder.setMainTextColor(it.toInt()) }
uiParams.acceptButtonTextColor?.let { builder.setAcceptButtonTextColor(it.toInt()) }
uiParams.cancelButtonTextColor?.let { builder.setCancelButtonTextColor(it.toInt()) }

builder.build()
} else {
TermsAndConditionsUIParams.builder().build()
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Build UI customization parameters if provided
val uiParams: TermsAndConditionsUIParams =
if (uiParams != null) {
val builder = TermsAndConditionsUIParams.builder()
// Apply custom colors if provided (convert from ARGB Long to Android Color Int)
uiParams.backgroundColor?.let { builder.setBackgroundColor(it.toInt()) }
uiParams.titleColor?.let { builder.setTitleColor(it.toInt()) }
uiParams.mainTextColor?.let { builder.setMainTextColor(it.toInt()) }
uiParams.acceptButtonTextColor?.let { builder.setAcceptButtonTextColor(it.toInt()) }
uiParams.cancelButtonTextColor?.let { builder.setCancelButtonTextColor(it.toInt()) }
builder.build()
} else {
TermsAndConditionsUIParams.builder().build()
}
// Build UI customization parameters if provided
val termsUiParams: TermsAndConditionsUIParams? =
uiParams?.let {
TermsAndConditionsUIParams.builder()
.apply {
it.backgroundColor?.let { color -> setBackgroundColor(color.toInt()) }
it.titleColor?.let { color -> setTitleColor(color.toInt()) }
it.mainTextColor?.let { color -> setMainTextColor(color.toInt()) }
it.acceptButtonTextColor?.let { color -> setAcceptButtonTextColor(color.toInt()) }
it.cancelButtonTextColor?.let { color -> setCancelButtonTextColor(color.toInt()) }
}
.build()
}

Comment on lines 569 to 586
if (shouldOnlyShowDriverAwarenessDisclaimer) {
val defaultParams: TermsAndConditionsUIParams = TermsAndConditionsUIParams.builder().build()
NavigationApi.showTermsAndConditionsDialog(
getActivity(),
companyName,
title,
defaultParams,
uiParams,
{ accepted -> callback(Result.success(accepted)) },
TermsAndConditionsCheckOption.SKIPPED,
)
} else {
NavigationApi.showTermsAndConditionsDialog(getActivity(), companyName, title) { accepted ->
callback(Result.success(accepted))
}
NavigationApi.showTermsAndConditionsDialog(
getActivity(),
companyName,
title,
uiParams,
{ accepted -> callback(Result.success(accepted)) },
)
}
Copy link
Contributor

@jokerttu jokerttu Dec 22, 2025

Choose a reason for hiding this comment

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

I couldn’t create a single GitHub suggestion covering the whole function, so I’m sharing these changes in separate parts. This one you must add manually as github did not allow to cover unchanges code part in suggestion.
The Android code failed to compile for multiple reasons. see check output. One issue was that showTermsAndConditionsDialog was invoked with an incorrect method signature in the else branch.

    val checkOption =
      if (shouldOnlyShowDriverAwarenessDisclaimer) TermsAndConditionsCheckOption.SKIPPED
      else TermsAndConditionsCheckOption.ENABLED

    NavigationApi.showTermsAndConditionsDialog(
      getActivity(),
      companyName,
      title,
      termsUiParams,
      { accepted -> callback(Result.success(accepted)) },
      checkOption,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request]: Add the ability to show custom UI for Google's Terms and Conditions

3 participants