49 lines
1.6 KiB
Dart
49 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../models/user_profile.dart';
|
|
import '../models/scripture.dart';
|
|
import '../theme/app_theme.dart';
|
|
import '../providers/user_provider.dart';
|
|
|
|
class BibleUtils {
|
|
static Future<void> showTranslationPicker(BuildContext context, WidgetRef ref) async {
|
|
final user = ref.read(userProfileProvider);
|
|
if (user == null) return;
|
|
|
|
final selected = await showModalBottomSheet<BibleTranslation>(
|
|
context: context,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
),
|
|
builder: (context) => Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
child: Text(
|
|
'Select Bible Translation',
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
),
|
|
...BibleTranslation.values.map((t) => ListTile(
|
|
title: Text(t.label),
|
|
trailing: user.bibleTranslation == t
|
|
? const Icon(Icons.check, color: AppColors.sageGreen)
|
|
: null,
|
|
onTap: () => Navigator.pop(context, t),
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
if (selected != null) {
|
|
await ref.read(userProfileProvider.notifier).updateProfile(
|
|
user.copyWith(bibleTranslation: selected)
|
|
);
|
|
}
|
|
}
|
|
}
|