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

Rename from CustomTabsBottomSheetConfiguration to PartialCustomTabsConfiguration #121

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flutter_custom_tabs/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class MyApp extends StatelessWidget {
try {
await launchUrl(
Uri.parse('https://flutter.dev'),
customTabsOptions: CustomTabsOptions.bottomSheet(
configuration: CustomTabsBottomSheetConfiguration(
customTabsOptions: CustomTabsOptions.partial(
configuration: PartialCustomTabsConfiguration(
initialHeight: mediaQuery.size.height * 0.7,
),
colorSchemes: CustomTabsColorSchemes.theme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CustomTabsFactory {
private static final String KEY_ANIMATION_END_ENTER = "endEnter";
private static final String KEY_ANIMATION_END_EXIT = "endExit";
private static final String KEY_OPTIONS_EXTRA_CUSTOM_TABS = "extraCustomTabs";
private static final String KEY_OPTIONS_BOTTOM_SHEET = "bottomSheet";
private static final String KEY_OPTIONS_PARTIAL_CUSTOM_TABS = "partial";
private static final String KEY_BOTTOM_SHEET_INITIAL_HEIGHT_DP = "initialHeightDp";
private static final String KEY_BOTTOM_SHEET_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR = "activityHeightResizeBehavior";
private static final String KEY_BOTTOM_SHEET_CORNER_RADIUS_DP = "cornerRadiusDp";
Expand Down Expand Up @@ -102,10 +102,10 @@ CustomTabsIntent createIntent(@NonNull Map<String, Object> options) {
applyAnimations(builder, ((Map<String, String>) options.get(KEY_OPTIONS_ANIMATIONS)));
}

if (options.containsKey(KEY_OPTIONS_BOTTOM_SHEET)) {
final Map<String, Object> bottomSheetConfig =
((Map<String, Object>) options.get(KEY_OPTIONS_BOTTOM_SHEET));
applyBottomSheetConfiguration(builder, bottomSheetConfig);
if (options.containsKey(KEY_OPTIONS_PARTIAL_CUSTOM_TABS)) {
final Map<String, Object> partialCustomTabsConfig =
((Map<String, Object>) options.get(KEY_OPTIONS_PARTIAL_CUSTOM_TABS));
applyPartialCustomTabsConfiguration(builder, partialCustomTabsConfig);
}

final CustomTabsIntent customTabsIntent = builder.build();
Expand Down Expand Up @@ -216,7 +216,7 @@ private void applyAnimations(
}
}

private void applyBottomSheetConfiguration(
private void applyPartialCustomTabsConfiguration(
@NonNull CustomTabsIntent.Builder builder,
@NonNull Map<String, Object> configuration
) {
Expand Down
4 changes: 2 additions & 2 deletions flutter_custom_tabs_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class MyApp extends StatelessWidget {
try {
await CustomTabsPlatform.instance.launch(
'https://flutter.dev',
customTabsOptions: CustomTabsOptions.bottomSheet(
configuration: CustomTabsBottomSheetConfiguration(
customTabsOptions: CustomTabsOptions.partial(
configuration: PartialCustomTabsConfiguration(
initialHeight: mediaQuery.size.height * 0.7,
),
colorSchemes: CustomTabsColorSchemes.theme(
Expand Down
4 changes: 2 additions & 2 deletions flutter_custom_tabs_ios/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class MyApp extends StatelessWidget {
try {
await CustomTabsPlatform.instance.launch(
'https://flutter.dev',
customTabsOptions: CustomTabsOptions.bottomSheet(
configuration: CustomTabsBottomSheetConfiguration(
customTabsOptions: CustomTabsOptions.partial(
configuration: PartialCustomTabsConfiguration(
initialHeight: mediaQuery.size.height * 0.7,
),
colorSchemes: CustomTabsColorSchemes.theme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class CustomTabsOptions {
this.animations,
this.extraCustomTabs,
this.headers,
this.bottomSheetConfiguration,
this.partialConfiguration,
});

/// Creates a [CustomTabsOptions] instance with bottom sheet configuration.
const CustomTabsOptions.bottomSheet({
required CustomTabsBottomSheetConfiguration configuration,
/// Creates a [CustomTabsOptions] instance with configuration for Partial Custom Tabs.
const CustomTabsOptions.partial({
required PartialCustomTabsConfiguration configuration,
CustomTabsColorSchemes? colorSchemes,
CustomTabsShareState? shareState,
bool? showTitle,
Expand All @@ -42,7 +42,7 @@ class CustomTabsOptions {
closeButton: closeButton,
extraCustomTabs: extraCustomTabs,
headers: headers,
bottomSheetConfiguration: configuration,
partialConfiguration: configuration,
);

/// The visualization configuration.
Expand Down Expand Up @@ -72,8 +72,8 @@ class CustomTabsOptions {
/// Extra HTTP request headers.
final Map<String, String>? headers;

/// The bottom sheet configuration.
final CustomTabsBottomSheetConfiguration? bottomSheetConfiguration;
/// The configuration for Partial Custom Tabs.
final PartialCustomTabsConfiguration? partialConfiguration;

/// Converts the [CustomTabsOptions] instance into a [Map] instance for serialization.
Map<String, dynamic> toMap() {
Expand All @@ -90,8 +90,8 @@ class CustomTabsOptions {
'closeButtonPosition': closeButton!.position!.rawValue,
if (extraCustomTabs != null) 'extraCustomTabs': extraCustomTabs,
if (headers != null) 'headers': headers,
if (bottomSheetConfiguration != null)
'bottomSheet': bottomSheetConfiguration!.toMap(),
if (partialConfiguration != null)
'partial': partialConfiguration!.toMap(),
};
}
}
Expand Down Expand Up @@ -298,10 +298,10 @@ enum CustomTabsShareState {
final int rawValue;
}

/// The configuration to show custom tab as a bottom sheet.
/// The configuration for [Partial Custom Tabs](https://developer.chrome.com/docs/android/custom-tabs/guide-partial-custom-tabs/).
@immutable
class CustomTabsBottomSheetConfiguration {
const CustomTabsBottomSheetConfiguration({
class PartialCustomTabsConfiguration {
const PartialCustomTabsConfiguration({
required this.initialHeight,
this.activityHeightResizeBehavior =
CustomTabsActivityHeightResizeBehavior.defaultBehavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
'com.microsoft.emmx',
],
headers: {'key': 'value'},
bottomSheetConfiguration: CustomTabsBottomSheetConfiguration(
partialConfiguration: PartialCustomTabsConfiguration(
initialHeight: 500,
activityHeightResizeBehavior:
CustomTabsActivityHeightResizeBehavior.adjustable,
Expand Down Expand Up @@ -94,7 +94,7 @@ void main() {
'com.microsoft.emmx',
],
'headers': <String, String>{'key': 'value'},
'bottomSheet': <String, dynamic>{
'partial': <String, dynamic>{
'initialHeightDp': 500,
'activityHeightResizeBehavior': 1,
'cornerRadiusDp': 16,
Expand Down Expand Up @@ -131,7 +131,7 @@ void main() {

group('CustomTabsBottomSheetConfiguration', () {
test('toMap() returns a map with complete options', () {
const configuration = CustomTabsBottomSheetConfiguration(
const configuration = PartialCustomTabsConfiguration(
initialHeight: 300,
activityHeightResizeBehavior:
CustomTabsActivityHeightResizeBehavior.adjustable,
Expand All @@ -145,7 +145,7 @@ void main() {
});

test('toMap() returns expected a map with default values', () {
const configuration = CustomTabsBottomSheetConfiguration(
const configuration = PartialCustomTabsConfiguration(
initialHeight: 200,
);
expect(configuration.toMap(), <String, dynamic>{
Expand Down