app-starlock/star_lock/lib/tools/showTFView.dart

101 lines
3.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../translations/trans_lib.dart';
class ShowTFView extends StatelessWidget {
String? title;
String? tipTitle;
String? leftBtnTitle;
String? rightBtnTitle;
TextEditingController? controller;
List<TextInputFormatter>? inputFormatters;
TextInputType? keyboardType;
Function()? sureClick;
Function()? cancelClick;
ShowTFView(
{Key? key,
this.title,
this.tipTitle,
this.leftBtnTitle,
this.rightBtnTitle,
this.controller,
this.inputFormatters,
this.keyboardType,
this.sureClick,
this.cancelClick})
: super(key: key);
@override
Widget build(BuildContext context) {
return Card(
color: const Color(0x00FFFFFF),
child: CupertinoAlertDialog(
title: Text(title!),
content: Column(
children: <Widget>[
const SizedBox(
height: 10,
),
Container(
height: 50.h,
// color: Colors.white,
// padding: EdgeInsets.only(left:20.w, right: 110.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15.w)),
child: TextField(
//输入框一行
maxLines: 1,
controller: controller,
autofocus: false,
inputFormatters: inputFormatters,
keyboardType: keyboardType,
decoration: InputDecoration(
contentPadding:
const EdgeInsets.only(left: 5, top: -8, bottom: 6),
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
hintStyle: TextStyle(fontSize: 22.sp, height: 1.0),
//不需要输入框下划线
border: InputBorder.none,
),
),
)
],
),
actions: <Widget>[
CupertinoDialogAction(
child: Text(
leftBtnTitle ?? TranslationLoader.lanKeys!.cancel!.tr,
style: const TextStyle(color: Colors.black),
),
onPressed: () {
// Navigator.pop(context);
// print("取消");
if (cancelClick != null) {
cancelClick!();
}
},
),
CupertinoDialogAction(
child: Text(
rightBtnTitle ?? TranslationLoader.lanKeys!.sure!.tr,
style: const TextStyle(color: Colors.black)),
onPressed: () {
if (sureClick != null) {
sureClick!();
}
// Navigator.pop(context);
// print("确定");
},
),
],
),
);
}
}