122 lines
3.4 KiB
Dart
122 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
|
|
|
import '../theme/app_text.dart';
|
|
import '../theme/spacing.dart';
|
|
|
|
Future<bool?> showLoginRequiredDialog(
|
|
BuildContext context, {
|
|
required String title,
|
|
required String description,
|
|
String cancelLabel = '取消',
|
|
String confirmLabel = '去登录',
|
|
}) {
|
|
final cs = ShadTheme.of(context).colorScheme;
|
|
return showModalBottomSheet<bool>(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
barrierColor: Colors.black.withValues(alpha: 0.5),
|
|
builder: (ctx) => Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: cs.background,
|
|
borderRadius: const BorderRadius.only(
|
|
topLeft: Radius.circular(Spacing.radiusCard),
|
|
topRight: Radius.circular(Spacing.radiusCard),
|
|
),
|
|
border: Border.all(color: cs.border),
|
|
),
|
|
padding: const EdgeInsets.fromLTRB(20, 12, 20, 20),
|
|
child: SafeArea(
|
|
top: false,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Center(
|
|
child: Container(
|
|
width: 38,
|
|
height: 4,
|
|
margin: const EdgeInsets.only(bottom: 16),
|
|
decoration: BoxDecoration(
|
|
color: cs.border,
|
|
borderRadius: BorderRadius.circular(9999),
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 19,
|
|
fontWeight: FontWeight.w700,
|
|
color: cs.foreground,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
description,
|
|
style: AppText.body.copyWith(
|
|
fontSize: 13,
|
|
height: 1.6,
|
|
color: cs.mutedForeground,
|
|
),
|
|
),
|
|
const SizedBox(height: 22),
|
|
_LoginSheetButton(
|
|
label: confirmLabel,
|
|
primary: true,
|
|
onTap: () => Navigator.of(ctx).pop(true),
|
|
),
|
|
const SizedBox(height: 12),
|
|
_LoginSheetButton(
|
|
label: cancelLabel,
|
|
primary: false,
|
|
onTap: () => Navigator.of(ctx).pop(false),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _LoginSheetButton extends StatelessWidget {
|
|
const _LoginSheetButton({
|
|
required this.label,
|
|
required this.primary,
|
|
required this.onTap,
|
|
});
|
|
|
|
final String label;
|
|
final bool primary;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final cs = ShadTheme.of(context).colorScheme;
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
behavior: HitTestBehavior.opaque,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 52,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: primary ? cs.primary : cs.secondary,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: primary ? null : Border.all(color: cs.border),
|
|
),
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: primary ? cs.primaryForeground : cs.foreground,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|