Files
saqel/apps/student_app/lib/presentation/widgets/luxury_widgets.dart
T

188 lines
5.1 KiB
Dart

import 'package:flutter/material.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_theme.dart';
/// Reusable Apple-Grade Frosted Glass Card
class LuxuryCard extends StatelessWidget {
final Widget child;
final EdgeInsetsGeometry padding;
final VoidCallback? onTap;
final Color? borderColor;
final Color? backgroundColor;
const LuxuryCard({
super.key,
required this.child,
this.padding = const EdgeInsets.all(20),
this.onTap,
this.borderColor,
this.backgroundColor,
});
@override
Widget build(BuildContext context) {
final cardWidget = Container(
padding: padding,
decoration: BoxDecoration(
color: backgroundColor ?? AppColors.darkCard,
borderRadius: BorderRadius.circular(22),
border: Border.all(
color: borderColor ?? AppColors.darkCardBorder,
width: 1,
),
boxShadow: const [
BoxShadow(
color: Color(0x66000000),
blurRadius: 25,
offset: Offset(0, 10),
),
],
),
child: child,
);
if (onTap != null) {
return GestureDetector(
onTap: onTap,
child: cardWidget,
);
}
return cardWidget;
}
}
/// Reusable Apple-Grade Primary Button
class LuxuryButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final Color? backgroundColor;
final Color? textColor;
final IconData? icon;
const LuxuryButton({
super.key,
required this.text,
required this.onPressed,
this.isLoading = false,
this.backgroundColor,
this.textColor,
this.icon,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: isLoading ? null : onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: backgroundColor ?? AppColors.appleBlue,
foregroundColor: textColor ?? Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
elevation: 0,
),
child: isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
Icon(icon, size: 20),
const SizedBox(width: 8),
],
Text(
text,
style: AppTypography.titleMedium.copyWith(
color: textColor ?? Colors.white,
fontWeight: FontWeight.w700,
),
),
],
),
);
}
}
/// Reusable Apple-Grade Text Field
class LuxuryTextField extends StatelessWidget {
final TextEditingController controller;
final String label;
final String hint;
final TextInputType keyboardType;
final Widget? prefixIcon;
final bool enabled;
final ValueChanged<String>? onChanged;
const LuxuryTextField({
super.key,
required this.controller,
this.label = '',
required this.hint,
this.keyboardType = TextInputType.text,
this.prefixIcon,
this.enabled = true,
this.onChanged,
});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (label.isNotEmpty) ...[
Text(
label,
style: AppTypography.titleMedium.copyWith(
color: AppColors.textSecondaryDark,
fontSize: 13,
),
),
const SizedBox(height: 8),
],
TextField(
controller: controller,
keyboardType: keyboardType,
enabled: enabled,
onChanged: onChanged,
style: AppTypography.bodyMedium.copyWith(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w600,
),
decoration: InputDecoration(
hintText: hint,
hintStyle: AppTypography.bodyMedium.copyWith(
color: AppColors.textMutedDark,
),
prefixIcon: prefixIcon,
filled: true,
fillColor: AppColors.darkSurface,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(color: AppColors.darkCardBorder),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(color: AppColors.darkCardBorder),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(color: AppColors.appleBlue, width: 1.5),
),
),
),
],
);
}
}