234 lines
7.3 KiB
Dart
234 lines
7.3 KiB
Dart
import 'dart:math';
|
|
import 'dart:ui';
|
|
|
|
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.black12);
|
|
dialog.style(
|
|
message: message,
|
|
messageTextStyle: Theme.of(context).textTheme.caption,
|
|
backgroundColor: Theme.of(context).dialogTheme.backgroundColor,
|
|
progressWidget: loadWidget,
|
|
borderRadius: 10,
|
|
elevation: 10.0,
|
|
insetAnimCurve: Curves.easeInOut,
|
|
);
|
|
return dialog;
|
|
}
|
|
|
|
Future<dynamic> showErrorDialog(
|
|
BuildContext context, String title, String content) {
|
|
AlertDialog alert = AlertDialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
title: Text(
|
|
title,
|
|
style: Theme.of(context).textTheme.headline2,
|
|
),
|
|
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 BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
|
child: alert,
|
|
);
|
|
},
|
|
barrierColor: Colors.black12,
|
|
);
|
|
}
|
|
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|