初始化项目
This commit is contained in:
86
lib/common/util/myDialog/MyDialog.dart
Normal file
86
lib/common/util/myDialog/MyDialog.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'my_dialog_controller.dart';
|
||||
|
||||
class MyDialog extends GetView<MyDialogController> {
|
||||
final String message;
|
||||
final int seconds;
|
||||
final Color? textColor; // 可选参数
|
||||
|
||||
MyDialog({
|
||||
required this.message,
|
||||
required this.seconds,
|
||||
this.textColor, // 可选参数的赋值
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 设置弹窗在2秒后自动关闭
|
||||
Timer(Duration(seconds: seconds), () {
|
||||
if (Navigator.canPop(context)) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent, // 使弹窗背景透明
|
||||
elevation: 0, // 去除阴影
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 232,
|
||||
maxHeight: 400,
|
||||
minHeight: 47,
|
||||
maxWidth: 400,
|
||||
),
|
||||
child: Opacity(
|
||||
opacity: 1, // 设置容器的透明度为80%
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// color: Color(0xFF182B7C),
|
||||
color: Color(0xFFffebe9),
|
||||
border: Border.all(
|
||||
// color: Color(0xFFe60012), // 边框颜色
|
||||
color: textColor ?? Color(0xFFe60012),
|
||||
width: 1, // 边框宽度
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
// color: Color(0xFFe60012), // 边框颜色
|
||||
color: textColor ?? Color(0xFFe60012),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
71
lib/common/util/myDialog/confirm_dialog.dart
Normal file
71
lib/common/util/myDialog/confirm_dialog.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
class ConfirmDialog extends GetView {
|
||||
ConfirmDialog();
|
||||
|
||||
Future showConfirmCustomDialog(BuildContext context,
|
||||
{String name = "是否确认取消?"}) async {
|
||||
// Completer<String> completer = Completer<String>();
|
||||
TextEditingController textEditingController = TextEditingController();
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Container(
|
||||
width: 340,
|
||||
padding: EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(alignment: Alignment.centerRight, child: closeIcon),
|
||||
Center(
|
||||
child: Text(
|
||||
'${name}',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 50.rpx, bottom: 40.rpx),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Get.back(result: "confirm");
|
||||
},
|
||||
child: Container(
|
||||
width: 280.rpx,
|
||||
height: 60.rpx,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: stringToColor("#D3B684")),
|
||||
child: Text(
|
||||
'确定',
|
||||
style: TextStyle(color: Colors.white, fontSize: 30.rpx),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
// return completer.future;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
44
lib/common/util/myDialog/my_dialog_controller.dart
Normal file
44
lib/common/util/myDialog/my_dialog_controller.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'MyDialog.dart';
|
||||
|
||||
part 'my_dialog_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class MyDialogModel {
|
||||
//版本id
|
||||
String? title_name = "标题"; //标题
|
||||
String? message = "消息内容";
|
||||
|
||||
MyDialogModel();
|
||||
|
||||
static MyDialogModel fromJson(Map<String, dynamic> json) =>
|
||||
_$MyDialogModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$MyDialogModelToJson(this);
|
||||
}
|
||||
|
||||
class MyDialogController extends GetControllerEx<MyDialogModel> {
|
||||
MyDialogController() {
|
||||
attr = GetModel(MyDialogModel()).obs;
|
||||
}
|
||||
|
||||
Future<void> showCustomDialog(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
Color? textColor, // 可选参数
|
||||
}) async {
|
||||
await showDialog(
|
||||
barrierColor: Colors.transparent, // 设置上级页面不变暗
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return MyDialog(
|
||||
message: message,
|
||||
seconds: 2,
|
||||
textColor: textColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
18
lib/common/util/myDialog/my_dialog_controller.g.dart
Normal file
18
lib/common/util/myDialog/my_dialog_controller.g.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'my_dialog_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MyDialogModel _$MyDialogModelFromJson(Map<String, dynamic> json) =>
|
||||
MyDialogModel()
|
||||
..title_name = json['title_name'] as String?
|
||||
..message = json['message'] as String?;
|
||||
|
||||
Map<String, dynamic> _$MyDialogModelToJson(MyDialogModel instance) =>
|
||||
<String, dynamic>{
|
||||
'title_name': instance.title_name,
|
||||
'message': instance.message,
|
||||
};
|
||||
Reference in New Issue
Block a user