app-starlock/lib/tools/pickers/style/default_style.dart
2024-05-18 09:37:50 +08:00

199 lines
6.5 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/style/picker_style.dart';
// import 'package:flutter_pickers/style/picker_style.dart';
// 日间圆角
const headDecorationLight = BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
/// 无标题样式
class NoTitleStyle extends PickerStyle {
NoTitleStyle() {
showTitleBar = false;
}
/// 夜间
NoTitleStyle.dark() {
showTitleBar = false;
backgroundColor = Colors.grey[800]!;
textColor = Colors.white;
}
}
/// 默认样式
class DefaultPickerStyle extends PickerStyle {
DefaultPickerStyle({bool haveRadius = false, String? title}) {
if (haveRadius) {
headDecoration = const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
if (title != null && title != '') {
this.title = Center(
child: Text(title, style: const TextStyle(color: Colors.grey, fontSize: 14)));
}
}
/// 夜间
DefaultPickerStyle.dark({bool haveRadius = false, String? title}) {
commitButton = Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 12, right: 22),
child: Text('确定'.tr, style: const TextStyle(color: Colors.white, fontSize: 16.0)),
);
cancelButton = Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 22, right: 12),
child: Text('取消'.tr, style: const TextStyle(color: Colors.white, fontSize: 16.0)),
);
headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius: !haveRadius
? null
: const BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
if (title != null && title != '') {
this.title = Center(
child: Text(title,
style: const TextStyle(color: Colors.white, fontSize: 14)));
}
backgroundColor = Colors.grey[800]!;
textColor = Colors.white;
}
}
/// 关闭按钮样式
class ClosePickerStyle extends PickerStyle {
/// 日间
ClosePickerStyle({bool haveRadius = false, String? title}) {
if (haveRadius) {
headDecoration = const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
cancelButton = const SizedBox();
if (title != null && title != '') {
this.title = Padding(
padding: const EdgeInsets.only(left: 16),
child: Align(
alignment: Alignment.centerLeft,
child: Text(title,
style: const TextStyle(color: Colors.grey, fontSize: 14))),
);
}
commitButton = Container(
// padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(right: 12),
child: const Icon(Icons.close, color: Colors.grey, size: 28),
);
}
/// 夜间
ClosePickerStyle.dark({bool haveRadius = false, String? title}) {
headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius: !haveRadius
? null
: const BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
cancelButton = const SizedBox();
commitButton = Container(
margin: const EdgeInsets.only(right: 12),
child: const Icon(Icons.close, color: Colors.white, size: 28),
);
if (title != null && title != '') {
this.title = Padding(
padding: const EdgeInsets.only(left: 16),
child: Align(
alignment: Alignment.centerLeft,
child: Text(title,
style: const TextStyle(color: Colors.white, fontSize: 14))),
);
}
backgroundColor = Colors.grey[800]!;
textColor = Colors.white;
}
}
/// 圆角按钮样式
class RaisedPickerStyle extends PickerStyle {
RaisedPickerStyle(
{bool haveRadius = false, String? title, Color color = Colors.blue}) {
if (haveRadius) {
headDecoration = const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
commitButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(right: 22),
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(4)),
child: Text('确定'.tr, style: const TextStyle(color: Colors.white, fontSize: 15.0)),
);
cancelButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(left: 22),
decoration: BoxDecoration(
border: Border.all(color: color, width: 1),
borderRadius: BorderRadius.circular(4)),
child: Text('取消'.tr, style: TextStyle(color: color, fontSize: 15.0)),
);
if (title != null && title != '') {
this.title = Center(
child: Text(title,
style: const TextStyle(color: Colors.grey, fontSize: 14)));
}
}
/// 夜间
RaisedPickerStyle.dark(
{bool haveRadius = false, String? title, Color? color}) {
headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius: !haveRadius
? null
: const BorderRadius.only(
topLeft: Radius.circular(10), topRight: Radius.circular(10)));
commitButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(right: 22),
decoration: BoxDecoration(
color: color ?? Colors.blue, borderRadius: BorderRadius.circular(4)),
child: Text('确定'.tr, style: const TextStyle(color: Colors.white, fontSize: 15.0)),
);
cancelButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(left: 22),
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 1),
borderRadius: BorderRadius.circular(4)),
child: Text('取消'.tr, style: const TextStyle(color: Colors.white, fontSize: 15.0)),
);
if (title != null && title != '') {
this.title = Center(
child: Text(title, style: const TextStyle(color: Colors.white, fontSize: 14)));
}
backgroundColor = Colors.grey[800]!;
textColor = Colors.white;
}
}