tsacdop-podcast-app-android/lib/util/general_dialog.dart

80 lines
2.9 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'extension_helper.dart';
2020-08-15 19:31:07 +02:00
Future generalDialog(BuildContext context,
{Widget title, Widget content, List<Widget> actions}) async =>
await showGeneralDialog(
context: context,
barrierDismissible: true,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.black54,
transitionDuration: const Duration(milliseconds: 200),
2020-07-26 12:20:42 +02:00
pageBuilder: (context, animaiton, secondaryAnimation) =>
AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
2020-08-15 19:31:07 +02:00
systemNavigationBarColor: context.brightness == Brightness.light
? Color.fromRGBO(113, 113, 113, 1)
: Color.fromRGBO(15, 15, 15, 1),
),
child: AlertDialog(
2020-08-11 10:36:27 +02:00
elevation: 2,
shape: RoundedRectangleBorder(
2020-08-15 19:31:07 +02:00
borderRadius: BorderRadius.circular(10.0)),
titlePadding: EdgeInsets.all(20),
2020-08-15 19:31:07 +02:00
title: SizedBox(width: context.width - 120, child: title),
content: content,
2020-08-01 17:09:51 +02:00
contentPadding: EdgeInsets.fromLTRB(20, 0, 20, 0),
actions: actions),
),
);
2020-08-15 19:31:07 +02:00
Future generalSheet(BuildContext context, {Widget child, String title}) async =>
await showModalBottomSheet(
2020-09-23 16:19:07 +02:00
useRootNavigator: true,
isScrollControlled: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0)),
),
elevation: 2,
context: context,
builder: (context) {
2020-09-23 16:19:07 +02:00
final statusHeight = MediaQuery.of(context).padding.top;
return SafeArea(
2020-09-23 16:19:07 +02:00
child: ConstrainedBox(
constraints:
BoxConstraints(maxHeight: context.height - statusHeight - 80),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
2020-09-23 16:19:07 +02:00
Container(
height: 4,
width: 25,
margin: EdgeInsets.only(top: 10.0, bottom: 2.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2.0),
color: context.primaryColorDark),
),
Padding(
padding: EdgeInsets.only(
left: 50, right: 50, top: 6.0, bottom: 15),
child: Text(
title,
style: context.textTheme.headline6,
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.clip,
),
),
Divider(height: 1),
2020-09-23 16:19:07 +02:00
Flexible(child: SingleChildScrollView(child: child)),
],
),
),
);
},
);