- Rename installed app display name to car64 (Android/iOS/Web titles) - Remove Buy Me a Coffee link from About screen - Update app version to 3.0.0+1 - Migrate scanner workflow to catalog-first flow: - look up in global_cars - show Found in Catalog bottom sheet for known cars - show New Discovery bottom sheet and insert into global_cars + car_votes - insert only into hotwheels for collection entries - Align garage reads to TPB schema by joining global_cars - Switch image field usage from image_url to user_image_url - Implement private-storage image service: - upload path auth.uid()/hotwheels.id.jpg - signed URL generation (1h) for display - in-app compression pipeline targeting <=500KB and max 1080px width - Use local brand fallback image assets/img/icon_bg_removed.png for missing car photos - Restrict edit dialog to personal notes (hotwheels) instead of global car metadata - Ensure first login auto-creates a default collection and owner membership
248 lines
8.1 KiB
Dart
248 lines
8.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../main.dart';
|
|
import '../theme/app_colors.dart';
|
|
import 'about_screen.dart';
|
|
|
|
/// Profile / settings tab.
|
|
class ProfileScreen extends StatelessWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final user = supabase.auth.currentUser;
|
|
final email = user?.email ?? 'unknown';
|
|
final createdAt = user?.createdAt;
|
|
final theme = Theme.of(context);
|
|
|
|
return Scaffold(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
// ── Header ──
|
|
SliverAppBar(
|
|
expandedHeight: 200,
|
|
pinned: true,
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
background: Container(
|
|
decoration: const BoxDecoration(
|
|
gradient: AppColors.brandGradient,
|
|
),
|
|
child: SafeArea(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
// Avatar
|
|
Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
border: Border.all(color: Colors.white, width: 3),
|
|
color: Colors.white.withValues(alpha: 0.2),
|
|
),
|
|
child: const Icon(
|
|
Icons.person,
|
|
size: 44,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
email,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.white.withValues(alpha: 0.95),
|
|
),
|
|
),
|
|
if (createdAt != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'Member since ${_formatDate(createdAt)}',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.white.withValues(alpha: 0.7),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
// ── Settings list ──
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'Account',
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
_SettingsTile(
|
|
icon: Icons.lock_outline,
|
|
title: 'Change Password',
|
|
onTap: () => _changePassword(context),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
'App',
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
_SettingsTile(
|
|
icon: Icons.info_outline,
|
|
title: 'About',
|
|
subtitle: 'car64',
|
|
onTap: () => _showAbout(context),
|
|
),
|
|
const SizedBox(height: 32),
|
|
|
|
// ── Sign out ──
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: OutlinedButton.icon(
|
|
onPressed: () async {
|
|
await supabase.auth.signOut();
|
|
},
|
|
icon: const Icon(Icons.logout, color: AppColors.error),
|
|
label: const Text(
|
|
'Sign Out',
|
|
style: TextStyle(color: AppColors.error),
|
|
),
|
|
style: OutlinedButton.styleFrom(
|
|
side: const BorderSide(color: AppColors.error),
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 40),
|
|
const Center(
|
|
child: Text(
|
|
'© 2026 car64',
|
|
style:
|
|
TextStyle(fontSize: 12, color: AppColors.textHint),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
static String _formatDate(String iso) {
|
|
final d = DateTime.tryParse(iso);
|
|
if (d == null) return iso;
|
|
const months = [
|
|
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
|
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
|
];
|
|
return '${months[d.month - 1]} ${d.year}';
|
|
}
|
|
|
|
void _changePassword(BuildContext context) {
|
|
final controller = TextEditingController();
|
|
showDialog(
|
|
context: context,
|
|
builder: (_) => AlertDialog(
|
|
title: const Text('Change Password'),
|
|
content: TextField(
|
|
controller: controller,
|
|
obscureText: true,
|
|
decoration: const InputDecoration(
|
|
labelText: 'New password',
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Cancel'),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
final pw = controller.text.trim();
|
|
if (pw.length < 6) {
|
|
showGlobalSnackBar('Password must be at least 6 characters.');
|
|
return;
|
|
}
|
|
try {
|
|
await supabase.auth.updateUser(
|
|
UserAttributes(password: pw),
|
|
);
|
|
if (context.mounted) Navigator.pop(context);
|
|
showGlobalSnackBar('Password updated!');
|
|
} on AuthException catch (e) {
|
|
showGlobalSnackBar(e.message, isError: true);
|
|
}
|
|
},
|
|
child: const Text('Save'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showAbout(BuildContext context) {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(builder: (_) => const AboutScreen()),
|
|
);
|
|
}
|
|
}
|
|
|
|
// ── Settings tile widget ──────────────────────────────────────────────
|
|
|
|
class _SettingsTile extends StatelessWidget {
|
|
final IconData icon;
|
|
final String title;
|
|
final String? subtitle;
|
|
final VoidCallback onTap;
|
|
|
|
const _SettingsTile({
|
|
required this.icon,
|
|
required this.title,
|
|
this.subtitle,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
|
child: ListTile(
|
|
leading: Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.orange.withValues(alpha: 0.1),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Icon(icon, color: AppColors.orange, size: 22),
|
|
),
|
|
title: Text(
|
|
title,
|
|
style: const TextStyle(fontWeight: FontWeight.w500),
|
|
),
|
|
subtitle: subtitle != null
|
|
? Text(subtitle!, style: const TextStyle(fontSize: 12))
|
|
: null,
|
|
trailing: const Icon(Icons.chevron_right, color: AppColors.textHint),
|
|
onTap: onTap,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
|
),
|
|
);
|
|
}
|
|
}
|