Main coves client
1import 'package:flutter/material.dart';
2
3import '../constants/app_colors.dart';
4
5/// Sign In Dialog
6///
7/// Shows a dialog prompting users to sign in before performing actions
8/// that require authentication (like voting, commenting, etc.)
9class SignInDialog extends StatelessWidget {
10 const SignInDialog({
11 this.title = 'Sign in required',
12 this.message = 'You need to sign in to interact with posts.',
13 super.key,
14 });
15
16 final String title;
17 final String message;
18
19 /// Show the dialog
20 static Future<bool?> show(
21 BuildContext context, {
22 String? title,
23 String? message,
24 }) {
25 return showDialog<bool>(
26 context: context,
27 builder:
28 (context) => SignInDialog(
29 title: title ?? 'Sign in required',
30 message: message ?? 'You need to sign in to interact with posts.',
31 ),
32 );
33 }
34
35 @override
36 Widget build(BuildContext context) {
37 return AlertDialog(
38 backgroundColor: AppColors.background,
39 title: Text(
40 title,
41 style: const TextStyle(
42 color: AppColors.textPrimary,
43 fontSize: 18,
44 fontWeight: FontWeight.bold,
45 ),
46 ),
47 content: Text(
48 message,
49 style: const TextStyle(color: AppColors.textSecondary, fontSize: 14),
50 ),
51 actions: [
52 TextButton(
53 onPressed: () => Navigator.of(context).pop(false),
54 child: const Text(
55 'Cancel',
56 style: TextStyle(color: AppColors.textSecondary),
57 ),
58 ),
59 ElevatedButton(
60 onPressed: () => Navigator.of(context).pop(true),
61 style: ElevatedButton.styleFrom(
62 backgroundColor: AppColors.primary,
63 foregroundColor: AppColors.textPrimary,
64 ),
65 child: const Text('Sign In'),
66 ),
67 ],
68 );
69 }
70}