You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.7 KiB
Dart
129 lines
3.7 KiB
Dart
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ConfirmDialog {
|
|
final BuildContext context;
|
|
|
|
final title;
|
|
final confirmMessage;
|
|
final okText;
|
|
final cancelText;
|
|
final Function okFunction;
|
|
final Function cancelFunction;
|
|
|
|
ConfirmDialog({@required this.context, this.title, @required this.confirmMessage, @required this.okText, @required this.cancelText, @required this.okFunction, @required this.cancelFunction});
|
|
|
|
showAlertDialog(BuildContext context) {
|
|
Dialog alert = Dialog(
|
|
child: Container(
|
|
color: Colors.transparent,
|
|
child: Mdialog(
|
|
context,
|
|
title != null ? title : TranslationBase.of(context).confirm,
|
|
confirmMessage,
|
|
okText,
|
|
cancelText,
|
|
cancelFunction: cancelFunction,
|
|
okFunction: okFunction,
|
|
),
|
|
),
|
|
);
|
|
|
|
// show the dialog
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return alert;
|
|
},
|
|
);
|
|
}
|
|
|
|
static closeAlertDialog(BuildContext context) {
|
|
Navigator.of(context).pop();
|
|
}
|
|
}
|
|
|
|
class Mdialog extends StatelessWidget {
|
|
String title;
|
|
String description;
|
|
final Function okFunction;
|
|
final Function cancelFunction;
|
|
final okText;
|
|
final cancelText;
|
|
BuildContext _context;
|
|
|
|
Mdialog(this._context, this.title, this.description, this.okText, this.cancelText, {this.okFunction, this.cancelFunction});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: containerRadius(Colors.white, 12),
|
|
padding: EdgeInsets.all(20),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
// title != null ? title : TranslationBase.of(context).confirm,
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 24,
|
|
letterSpacing: -0.94,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
// this.confirmMessage,
|
|
description,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
letterSpacing: -0.48,
|
|
color: CustomColors.grey,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
mHeight(16),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.of(_context).pop();
|
|
cancelFunction();
|
|
},
|
|
child: Container(
|
|
decoration: containerRadius(CustomColors.lightGreyColor, 12),
|
|
padding: EdgeInsets.only(top: 8,bottom: 8),
|
|
child: Center(child: Texts(cancelText)),
|
|
),
|
|
),
|
|
),
|
|
mWidth(8),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: okFunction,
|
|
child: Container(
|
|
decoration: containerRadius(CustomColors.accentColor, 12),
|
|
padding: EdgeInsets.only(top: 8,bottom: 8),
|
|
child: Center(
|
|
child: Texts(
|
|
okText,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|