Changed popup class structure
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:tallee/core/custom_theme.dart';
|
|
||||||
|
|
||||||
class AnimatedDialogButton extends StatefulWidget {
|
|
||||||
/// A custom animated button widget that provides a scaling and opacity effect
|
|
||||||
/// when pressed.
|
|
||||||
/// - [onPressed]: Callback function that is triggered when the button is pressed.
|
|
||||||
/// - [child]: The child widget to be displayed inside the button, typically a text or icon.
|
|
||||||
const AnimatedDialogButton({
|
|
||||||
super.key,
|
|
||||||
required this.onPressed,
|
|
||||||
required this.child,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Callback function that is triggered when the button is pressed.
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
/// The child widget to be displayed inside the button, typically a text or icon.
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
|
|
||||||
bool _isPressed = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTapDown: (_) => setState(() => _isPressed = true),
|
|
||||||
onTapUp: (_) => setState(() => _isPressed = false),
|
|
||||||
onTapCancel: () => setState(() => _isPressed = false),
|
|
||||||
onTap: widget.onPressed,
|
|
||||||
child: AnimatedScale(
|
|
||||||
scale: _isPressed ? 0.95 : 1.0,
|
|
||||||
duration: const Duration(milliseconds: 100),
|
|
||||||
child: AnimatedOpacity(
|
|
||||||
opacity: _isPressed ? 0.6 : 1.0,
|
|
||||||
duration: const Duration(milliseconds: 100),
|
|
||||||
child: Container(
|
|
||||||
decoration: CustomTheme.standardBoxDecoration,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 6),
|
|
||||||
child: widget.child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
84
lib/presentation/widgets/dialog/animated_dialog_button.dart
Normal file
84
lib/presentation/widgets/dialog/animated_dialog_button.dart
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tallee/core/enums.dart';
|
||||||
|
|
||||||
|
class AnimatedDialogButton extends StatefulWidget {
|
||||||
|
/// A custom animated button widget that provides a scaling and opacity effect
|
||||||
|
/// when pressed.
|
||||||
|
/// - [onPressed]: Callback function that is triggered when the button is pressed.
|
||||||
|
/// - [child]: The child widget to be displayed inside the button, typically a text or icon.
|
||||||
|
const AnimatedDialogButton({
|
||||||
|
super.key,
|
||||||
|
required this.onPressed,
|
||||||
|
required this.text,
|
||||||
|
this.buttonType = ButtonType.primary,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Callback function that is triggered when the button is pressed.
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
/// The text to be displayed on the button.
|
||||||
|
final String text;
|
||||||
|
|
||||||
|
final ButtonType buttonType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
|
||||||
|
bool _isPressed = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final textStyling = TextStyle(
|
||||||
|
color: widget.buttonType == ButtonType.primary
|
||||||
|
? Colors.black
|
||||||
|
: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
);
|
||||||
|
|
||||||
|
final buttonDecoration = widget.buttonType == ButtonType.primary
|
||||||
|
// Primary
|
||||||
|
? BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
)
|
||||||
|
: widget.buttonType == ButtonType.secondary
|
||||||
|
// Secondary
|
||||||
|
? BoxDecoration(
|
||||||
|
border: BoxBorder.all(color: Colors.white, width: 2),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
)
|
||||||
|
// Tertiary
|
||||||
|
: const BoxDecoration();
|
||||||
|
|
||||||
|
return GestureDetector(
|
||||||
|
onTapDown: (_) => setState(() => _isPressed = true),
|
||||||
|
onTapUp: (_) => setState(() => _isPressed = false),
|
||||||
|
onTapCancel: () => setState(() => _isPressed = false),
|
||||||
|
onTap: widget.onPressed,
|
||||||
|
child: AnimatedScale(
|
||||||
|
scale: _isPressed ? 0.95 : 1.0,
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: _isPressed ? 0.6 : 1.0,
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
constraints: const BoxConstraints(minWidth: 300),
|
||||||
|
decoration: buttonDecoration,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Text(
|
||||||
|
widget.text,
|
||||||
|
style: textStyling,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tallee/core/custom_theme.dart';
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
|
import 'package:tallee/presentation/widgets/dialog/custom_dialog_action.dart';
|
||||||
|
|
||||||
class CustomAlertDialog extends StatelessWidget {
|
class CustomAlertDialog extends StatelessWidget {
|
||||||
/// A custom alert dialog widget that provides a os unspecific AlertDialog,
|
/// A custom alert dialog widget that provides a os unspecific AlertDialog,
|
||||||
@@ -16,20 +17,23 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final String content;
|
final Widget content;
|
||||||
final List<Widget> actions;
|
final List<CustomDialogAction> actions;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(title, style: const TextStyle(color: CustomTheme.textColor)),
|
title: Text(
|
||||||
content: Text(
|
title,
|
||||||
content,
|
style: const TextStyle(
|
||||||
style: const TextStyle(color: CustomTheme.textColor),
|
fontWeight: FontWeight.bold,
|
||||||
|
color: CustomTheme.textColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
content: content,
|
||||||
actions: actions,
|
actions: actions,
|
||||||
backgroundColor: CustomTheme.boxColor,
|
backgroundColor: CustomTheme.boxColor,
|
||||||
actionsAlignment: MainAxisAlignment.spaceAround,
|
actionsAlignment: MainAxisAlignment.center,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||||
side: const BorderSide(color: CustomTheme.boxBorderColor),
|
side: const BorderSide(color: CustomTheme.boxBorderColor),
|
||||||
Reference in New Issue
Block a user