123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- import 'dart:math';
- import 'package:confetti/confetti.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/widgets.dart';
- import 'package:photos/ui/loading_widget.dart';
- import 'package:photos/ui/progress_dialog.dart';
- ProgressDialog createProgressDialog(BuildContext context, String message) {
- final dialog = ProgressDialog(
- context,
- type: ProgressDialogType.Normal,
- isDismissible: false,
- barrierColor: Colors.black.withOpacity(0.85),
- );
- dialog.style(
- message: message,
- messageTextStyle: TextStyle(color: Colors.white),
- backgroundColor: Color.fromRGBO(10, 15, 15, 1.0),
- progressWidget: loadWidget,
- borderRadius: 4.0,
- elevation: 10.0,
- insetAnimCurve: Curves.easeInOut,
- );
- return dialog;
- }
- Future<dynamic> showErrorDialog(
- BuildContext context, String title, String content) {
- AlertDialog alert = AlertDialog(
- title: Text(title),
- content: Text(content),
- actions: [
- TextButton(
- child: Text(
- "ok",
- style: TextStyle(
- color: Theme.of(context).colorScheme.onSurface,
- ),
- ),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop('dialog');
- },
- ),
- ],
- );
- return showDialog(
- context: context,
- builder: (BuildContext context) {
- return alert;
- },
- barrierColor: Colors.black87,
- );
- }
- Future<dynamic> showGenericErrorDialog(BuildContext context) {
- return showErrorDialog(context, "something went wrong", "please try again.");
- }
- Future<T> showConfettiDialog<T>({
- @required BuildContext context,
- WidgetBuilder builder,
- bool barrierDismissible = true,
- Color barrierColor,
- bool useSafeArea = true,
- bool useRootNavigator = true,
- RouteSettings routeSettings,
- Alignment confettiAlignment = Alignment.center,
- }) {
- final pageBuilder = Builder(
- builder: builder,
- );
- ConfettiController _confettiController =
- ConfettiController(duration: const Duration(seconds: 1));
- _confettiController.play();
- return showDialog(
- context: context,
- builder: (BuildContext buildContext) {
- return Stack(
- children: [
- pageBuilder,
- Align(
- alignment: confettiAlignment,
- child: ConfettiWidget(
- confettiController: _confettiController,
- blastDirection: pi / 2,
- emissionFrequency: 0,
- numberOfParticles: 100, // a lot of particles at once
- gravity: 1,
- blastDirectionality: BlastDirectionality.explosive,
- ),
- ),
- ],
- );
- },
- barrierDismissible: barrierDismissible,
- barrierColor: barrierColor,
- useSafeArea: useSafeArea,
- useRootNavigator: useRootNavigator,
- routeSettings: routeSettings,
- );
- }
- Widget test() {
- return Container(
- width: 355,
- height: 236,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Container(
- width: 355,
- height: 236,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- color: Color(0x4c000000),
- ),
- padding: const EdgeInsets.only(
- top: 20,
- bottom: 16,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- width: 234,
- child: Text(
- "Are you sure you want to logout?",
- style: TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontFamily: "SF Pro Display",
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- SizedBox(height: 16),
- Container(
- width: 323,
- height: 48,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Container(
- width: 323,
- height: 48,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- color: Color(0x4c000000),
- ),
- padding: const EdgeInsets.only(
- left: 135,
- right: 136,
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(
- "Cancel",
- style: TextStyle(
- color: Colors.white,
- fontSize: 16,
- fontFamily: "SF Pro Text",
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- SizedBox(height: 16),
- Container(
- width: 323,
- height: 48,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Container(
- width: 323,
- height: 48,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- color: Colors.white,
- ),
- padding: const EdgeInsets.symmetric(
- horizontal: 120,
- vertical: 12,
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(
- "Yes Logout",
- style: TextStyle(
- color: Colors.black,
- fontSize: 16,
- fontFamily: "SF Pro Text",
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
|