Skip to content

Commit

Permalink
Hide the custom URL field if we use the PROD
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jan 29, 2025
1 parent b9e0a23 commit ab20f73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ class UserPreferencesDevMode extends AbstractUserPreferences {
.getPostUri(path: '')
.toString(),
),
visibleWhen: (BuildContext context) {
return userPreferences.getFlag(userPreferencesFlagProd) == false;
},
onTap: () async => _changeTestEnvDomain(),
),
const UserPreferencesItemSection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ class UserPreferencesItemTile implements UserPreferencesItem {
this.onTap,
this.leading,
this.trailing,
this.visibleWhen,
});

final String title;
final String? subtitle;
final VoidCallback? onTap;
final Widget? leading;
final Widget? trailing;
final bool Function(BuildContext context)? visibleWhen;

@override
List<String> get labels => <String>[
Expand All @@ -129,13 +131,19 @@ class UserPreferencesItemTile implements UserPreferencesItem {
];

@override
WidgetBuilder get builder => (final BuildContext context) => ListTile(
title: Text(title),
subtitle: subtitle == null ? null : Text(subtitle!),
onTap: onTap,
leading: leading,
trailing: trailing,
);
WidgetBuilder get builder => (final BuildContext context) {
if (visibleWhen?.call(context) == false) {
return EMPTY_WIDGET;
}

return ListTile(
title: Text(title),
subtitle: subtitle == null ? null : Text(subtitle!),
onTap: onTap,
leading: leading,
trailing: trailing,
);
};
}

/// Same as [UserPreferencesItemTile] but with [WidgetBuilder].
Expand Down

0 comments on commit ab20f73

Please sign in to comment.