mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
first google play release for internal testing
This commit is contained in:
+167
-186
@@ -5,7 +5,6 @@ import '../../core/l10n/app_strings.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../providers/current_user_provider.dart';
|
||||
import '../providers/google_drive_provider.dart';
|
||||
import '../providers/premium_provider.dart';
|
||||
import 'error_snackbar.dart';
|
||||
|
||||
@@ -20,14 +19,16 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool _purchasing = false;
|
||||
bool _restoring = false;
|
||||
bool _resetting = false;
|
||||
bool _showSuccess = false;
|
||||
String _successTitle = '';
|
||||
late final AnimationController _successController;
|
||||
late final Animation<double> _successScale;
|
||||
|
||||
static const _gradientColors = [
|
||||
Color(0xFF1B5E20),
|
||||
Color(0xFF2E7D32),
|
||||
Color(0xFF4CAF8C),
|
||||
Color(0xFF5B4DCC),
|
||||
Color(0xFF7C6DED),
|
||||
Color(0xFF9D8FF5),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -51,8 +52,11 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showSuccessOverlay() {
|
||||
setState(() => _showSuccess = true);
|
||||
void _showSuccessOverlay(String title) {
|
||||
setState(() {
|
||||
_successTitle = title;
|
||||
_showSuccess = true;
|
||||
});
|
||||
_successController.forward(from: 0.0);
|
||||
}
|
||||
|
||||
@@ -67,8 +71,6 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isPremium = ref.watch(isPremiumProvider);
|
||||
final driveUserAsync = ref.watch(googleDriveUserProvider);
|
||||
final driveUser = driveUserAsync.value;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Stack(
|
||||
@@ -77,7 +79,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeader(context, s, colorScheme),
|
||||
_buildHeader(context),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
@@ -85,13 +87,10 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
_buildHeroBanner(context, s, colorScheme, isPremium),
|
||||
_buildHeroBanner(context, s, isPremium),
|
||||
const SizedBox(height: 20),
|
||||
_buildFeatureList(context, s, colorScheme),
|
||||
const SizedBox(height: 16),
|
||||
if (isPremium) ...[
|
||||
_buildProActiveSection(context, s, colorScheme, driveUser),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -106,11 +105,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
|
||||
child: Row(
|
||||
@@ -127,7 +122,6 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
Widget _buildHeroBanner(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
bool isVip,
|
||||
) {
|
||||
return Container(
|
||||
@@ -209,7 +203,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
s.proPurchaseSuccess,
|
||||
_successTitle,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: colorScheme.onSurface,
|
||||
@@ -240,7 +234,6 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
final features = [
|
||||
(Icons.cloud_sync_rounded, s.proFeatureCloudSync, s.proFeatureCloudSyncDesc),
|
||||
(Icons.analytics_rounded, s.proFeatureAnalytics, s.proFeatureAnalyticsDesc),
|
||||
(Icons.palette_rounded, s.proFeatureCustomization, s.proFeatureCustomizationDesc),
|
||||
(Icons.fingerprint_rounded, s.proFeatureBiometric, s.proFeatureBiometricDesc),
|
||||
@@ -295,116 +288,12 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProActiveSection(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
dynamic googleUser,
|
||||
) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: colorScheme.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (googleUser != null) ...[
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.email_outlined, size: 18, color: colorScheme.onSurface.withOpacity(0.5)),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
googleUser.email,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.sync_rounded, size: 18, color: colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
s.proSyncEnabled,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(Icons.check_circle_rounded, color: colorScheme.primary, size: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.backup_outlined, size: 18, color: colorScheme.onSurface.withOpacity(0.5)),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${s.proLastBackup}: —',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _handleGoogleSignOut,
|
||||
icon: Icon(Icons.logout_rounded, color: colorScheme.error),
|
||||
label: Text(s.proSignOut),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
] else ...[
|
||||
Text(
|
||||
s.proSignInForSync,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _handleGoogleSignIn,
|
||||
icon: Icon(Icons.login_rounded, color: colorScheme.primary),
|
||||
label: Text(s.proSignInGoogle),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomBar(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
bool isVip,
|
||||
) {
|
||||
if (isVip) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
|
||||
decoration: BoxDecoration(
|
||||
@@ -419,51 +308,124 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: _purchasing ? null : _handlePurchase,
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
if (!isVip) ...[
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: _purchasing ? null : _handlePurchase,
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: _purchasing
|
||||
? SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
s.proBuy,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: _restoring ? null : _handleRestore,
|
||||
child: _restoring
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
: Text(s.proRestorePurchases),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: colorScheme.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: _purchasing
|
||||
? SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
s.proBuy,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.verified_rounded,
|
||||
color: colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
s.proActive,
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: _restoring ? null : _handleRestore,
|
||||
child: _restoring
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.primary,
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _resetting ? null : _handleResetData,
|
||||
icon: _resetting
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
Icons.restart_alt_rounded,
|
||||
size: 18,
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
)
|
||||
: Text(s.proRestorePurchases),
|
||||
label: Text(
|
||||
s.proResetData,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
side: BorderSide(
|
||||
color: colorScheme.onSurface.withOpacity(0.15),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -478,7 +440,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
if (result.success) {
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
_showSuccessOverlay();
|
||||
_showSuccessOverlay(ref.read(stringsProvider).proPurchaseSuccess);
|
||||
HapticService.medium();
|
||||
}
|
||||
} else {
|
||||
@@ -504,7 +466,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
if (result.success) {
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
_showSuccessOverlay();
|
||||
_showSuccessOverlay(ref.read(stringsProvider).proRestoreSuccessTitle);
|
||||
HapticService.medium();
|
||||
}
|
||||
} else {
|
||||
@@ -521,27 +483,46 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleGoogleSignIn() async {
|
||||
HapticService.light();
|
||||
try {
|
||||
final service = ref.read(googleDriveServiceProvider);
|
||||
await service.signIn();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleGoogleSignOut() async {
|
||||
HapticService.light();
|
||||
try {
|
||||
final service = ref.read(googleDriveServiceProvider);
|
||||
await service.signOut();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
}
|
||||
Future<void> _handleResetData() async {
|
||||
final s = ref.read(stringsProvider);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(s.proResetData),
|
||||
content: Text(s.proResetDataConfirm),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(ctx);
|
||||
HapticService.light();
|
||||
setState(() => _resetting = true);
|
||||
try {
|
||||
final manager = ref.read(premiumManagerProvider);
|
||||
await manager.clear();
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
showSuccessSnackbar(context, s.proResetDataSuccess);
|
||||
HapticService.medium();
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _resetting = false);
|
||||
}
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFE05C6B),
|
||||
),
|
||||
child: Text(s.proResetData),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user