mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 09:41:13 +03:00
172 lines
6.2 KiB
Dart
172 lines
6.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../core/l10n/locale_provider.dart';
|
|
import '../../core/services/haptic_service.dart';
|
|
import '../providers/google_drive_provider.dart';
|
|
import '../providers/premium_provider.dart';
|
|
|
|
class ProSubscriptionCard extends ConsumerWidget {
|
|
const ProSubscriptionCard({super.key});
|
|
|
|
static const _gradientColors = [
|
|
Color(0xFF283593),
|
|
Color(0xFF5E35B1),
|
|
Color(0xFFD81B60),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final s = ref.watch(stringsProvider);
|
|
final isPremium = ref.watch(isPremiumProvider);
|
|
final driveUserAsync = ref.watch(googleDriveUserProvider);
|
|
final driveUser = driveUserAsync.value;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: _gradientColors,
|
|
),
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Icon(
|
|
isPremium
|
|
? Icons.verified_rounded
|
|
: Icons.workspace_premium_rounded,
|
|
color: Colors.white,
|
|
size: 28,
|
|
),
|
|
),
|
|
const SizedBox(width: 14),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
s.proTitle,
|
|
style:
|
|
Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
fontWeight: FontWeight.w900,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
isPremium ? s.proActive : s.proSubtitle,
|
|
style: isPremium
|
|
? Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Colors.white.withOpacity(0.9),
|
|
fontWeight: FontWeight.w600,
|
|
)
|
|
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
color: Colors.white.withOpacity(0.7),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
if (!isPremium) ...[
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton(
|
|
onPressed: () {
|
|
HapticService.light();
|
|
context.push('/pro');
|
|
},
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
side: BorderSide(
|
|
color: Colors.white.withOpacity(0.4), width: 1.5),
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: Text(
|
|
s.proAboutPro,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.w700, fontSize: 15),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
] else ...[
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
HapticService.light();
|
|
context.push('/backup');
|
|
},
|
|
icon: Icon(
|
|
driveUser != null
|
|
? Icons.cloud_done_rounded
|
|
: Icons.cloud_sync_rounded,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
label: Text(s.backupSyncWithDrive),
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
side: BorderSide(
|
|
color: Colors.white.withOpacity(0.4), width: 1.5),
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (driveUser == null) ...[
|
|
const SizedBox(height: 10),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
HapticService.light();
|
|
ref.read(googleDriveServiceProvider).signIn();
|
|
},
|
|
icon: const Icon(Icons.login_rounded,
|
|
color: Colors.white, size: 18),
|
|
label: Text(s.proSignInGoogle),
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
side: BorderSide(
|
|
color: Colors.white.withOpacity(0.3), width: 1),
|
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|