148 lines
4.7 KiB
Dart
148 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_application_1/core/theme/app_colors.dart';
|
|
|
|
class SessionNameDialog extends StatefulWidget {
|
|
final String title;
|
|
final String hintText;
|
|
final String confirmText;
|
|
final String cancelText;
|
|
|
|
const SessionNameDialog({
|
|
super.key,
|
|
this.title = 'Save Ride Session',
|
|
this.hintText = 'Enter session name',
|
|
this.confirmText = 'Save',
|
|
this.cancelText = 'Cancel',
|
|
});
|
|
|
|
static Future<String?> show(BuildContext context) {
|
|
return showDialog<String>(
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (_) => const SessionNameDialog(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
State<SessionNameDialog> createState() => _SessionNameDialogState();
|
|
}
|
|
|
|
class _SessionNameDialogState extends State<SessionNameDialog> {
|
|
late final TextEditingController _controller;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = TextEditingController();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
insetPadding: const EdgeInsets.symmetric(horizontal: 24),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
widget.title,
|
|
style: const TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textDark,
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
const Text(
|
|
'Give this ride a name before saving it to your session history.',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
height: 1.5,
|
|
color: AppColors.textMuted,
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
TextField(
|
|
controller: _controller,
|
|
autofocus: true,
|
|
onChanged: (_) => setState(() {}),
|
|
decoration: InputDecoration(
|
|
hintText: widget.hintText,
|
|
filled: true,
|
|
fillColor: AppColors.lightBlue,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 18,
|
|
vertical: 18,
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: const BorderSide(color: AppColors.inputBorder),
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: const BorderSide(
|
|
color: AppColors.primaryBlue,
|
|
width: 1.4,
|
|
),
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
style: OutlinedButton.styleFrom(
|
|
minimumSize: const Size.fromHeight(54),
|
|
side: const BorderSide(color: AppColors.inputBorder),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
),
|
|
child: Text(
|
|
widget.cancelText,
|
|
style: const TextStyle(
|
|
color: AppColors.textDark,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: ElevatedButton(
|
|
onPressed: () => Navigator.of(context).pop(_controller.text.trim()),
|
|
style: ElevatedButton.styleFrom(
|
|
minimumSize: const Size.fromHeight(54),
|
|
backgroundColor: AppColors.primaryBlue,
|
|
foregroundColor: AppColors.white,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
),
|
|
child: Text(
|
|
widget.confirmText,
|
|
style: const TextStyle(fontWeight: FontWeight.w800),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|