Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Create unified RoundedButton component with primary/secondary variants

Prateek Sunal225e417e7cfb
diff --git a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart
index 6cd5f34ca9..ba4442dc56 100644
--- a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart
+++ b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart
@@ -16,6 +16,7 @@ import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/account/logout_dialog.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
+import 'package:ente_auth/ui/home/widgets/rounded_action_buttons.dart';
import 'package:ente_auth/ui/home_page.dart';
import 'package:ente_auth/ui/settings/developer_settings_page.dart';
import 'package:ente_auth/ui/settings/developer_settings_widget.dart';
@@ -161,50 +162,18 @@ class _OnboardingPageState extends State<OnboardingPage> {
child: Row(
children: [
Expanded(
- child: GestureDetector(
- onTap: _navigateToSignUpPage,
- child: Container(
- padding: const EdgeInsets.symmetric(
- vertical: 18,
- ),
- decoration: BoxDecoration(
- color: Colors.white.withValues(alpha: 0.2),
- borderRadius: BorderRadius.circular(20),
- ),
- child: Center(
- child: Text(
- l10n.signUp,
- style: textTheme.body.copyWith(
- color: Colors.white,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
+ child: RoundedButton(
+ label: l10n.signUp,
+ onPressed: _navigateToSignUpPage,
+ type: RoundedButtonType.secondaryInverse,
),
),
const SizedBox(width: 6),
Expanded(
- child: GestureDetector(
- onTap: _navigateToSignInPage,
- child: Container(
- padding: const EdgeInsets.symmetric(
- vertical: 18,
- ),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(20),
- ),
- child: Center(
- child: Text(
- l10n.logInLabel,
- style: textTheme.body.copyWith(
- color: accentColor,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
+ child: RoundedButton(
+ label: l10n.logInLabel,
+ onPressed: _navigateToSignInPage,
+ type: RoundedButtonType.primaryInverse,
),
),
],
diff --git a/mobile/apps/auth/lib/ui/home/home_empty_state.dart b/mobile/apps/auth/lib/ui/home/home_empty_state.dart
index 71633b22ee..3d8e967775 100644
--- a/mobile/apps/auth/lib/ui/home/home_empty_state.dart
+++ b/mobile/apps/auth/lib/ui/home/home_empty_state.dart
@@ -97,19 +97,20 @@ class HomeEmptyStateWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (PlatformUtil.isMobile()) ...[
- PrimaryRoundedButton(
+ RoundedButton(
label: l10n.importScanQrCode,
onPressed: onScanTap,
width: double.infinity,
),
const SizedBox(height: 12),
- SecondaryRoundedButton(
+ RoundedButton(
label: l10n.importEnterSetupKey,
onPressed: onManuallySetupTap,
width: double.infinity,
+ type: RoundedButtonType.secondary,
),
] else
- PrimaryRoundedButton(
+ RoundedButton(
label: l10n.importEnterSetupKey,
onPressed: onManuallySetupTap,
width: double.infinity,
diff --git a/mobile/apps/auth/lib/ui/home/widgets/rounded_action_buttons.dart b/mobile/apps/auth/lib/ui/home/widgets/rounded_action_buttons.dart
index 49e645ff3e..03bf70ccaf 100644
--- a/mobile/apps/auth/lib/ui/home/widgets/rounded_action_buttons.dart
+++ b/mobile/apps/auth/lib/ui/home/widgets/rounded_action_buttons.dart
@@ -2,58 +2,25 @@ import 'package:ente_auth/theme/colors.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:flutter/material.dart';
-class PrimaryRoundedButton extends StatelessWidget {
- final String label;
- final VoidCallback? onPressed;
- final double? width;
-
- const PrimaryRoundedButton({
- super.key,
- required this.label,
- required this.onPressed,
- this.width,
- });
-
- @override
- Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
-
- return GestureDetector(
- onTap: onPressed,
- child: Container(
- width: width,
- height: 56,
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 18),
- decoration: ShapeDecoration(
- color: accentColor,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20),
- ),
- ),
- child: Center(
- child: Text(
- label,
- style: textTheme.small.copyWith(
- color: Colors.white,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
- );
- }
+enum RoundedButtonType {
+ primary,
+ secondary,
+ primaryInverse,
+ secondaryInverse,
}
-class SecondaryRoundedButton extends StatelessWidget {
+class RoundedButton extends StatelessWidget {
final String label;
final VoidCallback? onPressed;
final double? width;
+ final RoundedButtonType type;
- const SecondaryRoundedButton({
+ const RoundedButton({
super.key,
required this.label,
required this.onPressed,
this.width,
+ this.type = RoundedButtonType.primary,
});
@override
@@ -61,8 +28,19 @@ class SecondaryRoundedButton extends StatelessWidget {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
final isDarkTheme = !colorScheme.isLightTheme;
- final backgroundColor =
- isDarkTheme ? const Color(0x29A75CFF) : const Color(0x0AA75CFF);
+
+ final (backgroundColor, textColor) = switch (type) {
+ RoundedButtonType.primary => (accentColor, Colors.white),
+ RoundedButtonType.secondary => (
+ isDarkTheme ? const Color(0x29A75CFF) : const Color(0x0AA75CFF),
+ colorScheme.textBase,
+ ),
+ RoundedButtonType.primaryInverse => (Colors.white, accentColor),
+ RoundedButtonType.secondaryInverse => (
+ Colors.white.withValues(alpha: 0.2),
+ Colors.white,
+ ),
+ };
return GestureDetector(
onTap: onPressed,
@@ -80,7 +58,7 @@ class SecondaryRoundedButton extends StatelessWidget {
child: Text(
label,
style: textTheme.small.copyWith(
- color: colorScheme.textBase,
+ color: textColor,
fontWeight: FontWeight.w600,
),
),