修改未完成国际化字段

This commit is contained in:
魏少阳 2024-08-20 09:53:39 +08:00
parent b25bf61db1
commit e817883575
22 changed files with 256 additions and 209 deletions

View File

@ -861,5 +861,15 @@
"QQ空间": "QQZone",
"微博": "Weibo",
"FaceBook": "FaceBook",
"链接": "Link"
"链接": "Link",
"今天": "Today",
"密码错误": "Password error",
"网络中断": "Network interruption",
"钥匙不存在": "Key does not exist",
"钥匙过期": "Key expired",
"钥匙已存在": "Key already exists",
"密码失效": "Password invalid",
"门锁时间异常": "Door lock time abnormal",
"APP(手机)未联网": "APP (mobile phone) is not connected to the Internet",
"数据不存在": "Data does not exist"
}

View File

@ -893,5 +893,15 @@
"QQ空间": "QQ空间",
"微博": "微博",
"FaceBook": "FaceBook",
"链接": "链接"
"链接": "链接",
"今天": "今天",
"密码错误": "密码错误",
"网络中断": "网络中断",
"钥匙不存在": "钥匙不存在",
"钥匙过期": "钥匙过期",
"钥匙已存在": "钥匙已存在",
"密码失效": "密码失效",
"门锁时间异常": "门锁时间异常",
"APP(手机)未联网": "APP(手机)未联网",
"数据不存在": "数据不存在"
}

View File

@ -859,5 +859,15 @@
"QQ空间": "QQ空间",
"微博": "微博",
"FaceBook": "FaceBook",
"链接": "链接"
"链接": "链接",
"今天": "今天",
"密码错误": "密码错误",
"网络中断": "网络中断",
"钥匙不存在": "钥匙不存在",
"钥匙过期": "钥匙过期",
"钥匙已存在": "钥匙已存在",
"密码失效": "密码失效",
"门锁时间异常": "门锁时间异常",
"APP(手机)未联网": "APP(手机)未联网",
"数据不存在": "数据不存在"
}

View File

@ -120,23 +120,23 @@ class AppColors {
static Color progressBgColor = const Color(0xFF022345);
static Color progressValueColor = const Color(0xFF0093E5);
static const greyLineColor = Color.fromRGBO(240, 240, 240, 1); //线220
static const darkGrayTextColor = Color.fromRGBO(65, 65, 65, 1); //
static const placeholderTextColor = Color.fromRGBO(128, 128, 128, 1); //
static const greyBackgroundColor = Color.fromRGBO(240, 240, 240, 1); //
static const btnDisableColor = Color.fromRGBO(178, 178, 178, 1); //
static const toBeReceiveBgColor = Color.fromRGBO(246, 203, 203, 1); //
static const expireTextBgColor = Color.fromRGBO(253, 166, 8, 1); //
static const blueTextTipsColor = Color.fromRGBO(0, 113, 255, 1); //tips
static const blueViewBgColor =
static const Color greyLineColor = Color.fromRGBO(240, 240, 240, 1); //线220
static const Color darkGrayTextColor = Color.fromRGBO(65, 65, 65, 1); //
static const Color placeholderTextColor = Color.fromRGBO(128, 128, 128, 1); //
static const Color greyBackgroundColor = Color.fromRGBO(240, 240, 240, 1); //
static const Color btnDisableColor = Color.fromRGBO(178, 178, 178, 1); //
static const Color toBeReceiveBgColor = Color.fromRGBO(246, 203, 203, 1); //
static const Color expireTextBgColor = Color.fromRGBO(253, 166, 8, 1); //
static const Color blueTextTipsColor = Color.fromRGBO(0, 113, 255, 1); //tips
static const Color blueViewBgColor =
Color.fromRGBO(223, 237, 254, 1); // 139 148 176
static const msgNoticeTextColor = Color.fromRGBO(139, 148, 176, 1); //
static const alphaBgViewColor = Color.fromRGBO(0, 0, 0, 0.2); //
static const vipFeatureBgColor =
static const Color msgNoticeTextColor = Color.fromRGBO(139, 148, 176, 1); //
static const Color alphaBgViewColor = Color.fromRGBO(0, 0, 0, 0.2); //
static const Color vipFeatureBgColor =
Color.fromRGBO(251, 248, 229, 1); //
static const vipFeatureBtnBgColor =
static const Color vipFeatureBtnBgColor =
Color.fromRGBO(197, 167, 109, 1); //
static const vipFeatureBtnTextColor =
static const Color vipFeatureBtnTextColor =
Color.fromRGBO(110, 98, 81, 1); //
static Color openPassageModeColor = const Color(0xFFEB2A3B); // ()

View File

@ -1,7 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/about/debug/debug_console.dart';
class AppLog {
@ -103,7 +103,7 @@ class AppDate {
static int timeZeroOffset() => DateTime.now().timeZoneOffset.inHours;
}
//TODO:
//
enum ErrorType {
modeNotMatch,
notConnected,

View File

@ -24,27 +24,27 @@ abstract class Reply{
case 0x01:
//
AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误');
showErrorMessage('包格式错误');
// showErrorMessage('包格式错误');
break;
case 0x02:
//
AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误');
showErrorMessage('密码错误');
showErrorMessage('密码错误'.tr);
break;
case 0x03:
//
AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断');
showErrorMessage('网络中断');
showErrorMessage('网络中断'.tr);
break;
case 0x04:
//
AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记');
showErrorMessage('用户未登记');
// showErrorMessage('用户未登记');
break;
case 0x05:
//
AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误');
showErrorMessage('参数错误');
// showErrorMessage('参数错误');
break;
case 0x06:
//
@ -59,42 +59,42 @@ abstract class Reply{
case 0x08:
//
AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时');
showErrorMessage('应答超时');
// showErrorMessage('应答超时');
break;
case 0x09:
//
AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误');
showErrorMessage('权限校验错误');
// showErrorMessage('权限校验错误');
break;
case 0x0a:
//
showErrorMessage('钥匙不存在');
showErrorMessage('钥匙不存在'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在');
break;
case 0x0b:
//
showErrorMessage('钥匙过期');
showErrorMessage('钥匙过期'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期');
break;
case 0x0c:
//
showErrorMessage('钥匙数量已到上限');
// showErrorMessage('钥匙数量已到上限');
AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限');
break;
case 0x0d:
//
showErrorMessage('钥匙无效');
showErrorMessage('钥匙无效'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效');
break;
case 0x0e:
//
showErrorMessage('钥匙已存在');
showErrorMessage('钥匙已存在'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在');
break;
case 0x0f:
//
AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在');
showErrorMessage('用户已存在');
// showErrorMessage('用户已存在');
break;
case 0x10:
//
@ -104,27 +104,27 @@ abstract class Reply{
case 0x11:
//
AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令');
showErrorMessage('无效指令');
// showErrorMessage('无效指令');
break;
case 0x12:
//
AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常');
showErrorMessage('门锁时间异常');
showErrorMessage('门锁时间异常'.tr);
break;
case 0x15:
// APP()
AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网');
showErrorMessage('APP(手机)未联网');
showErrorMessage('APP(手机)未联网'.tr);
break;
case 0x16:
// ...
AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...');
showErrorMessage('正在开锁中...');
showErrorMessage('正在开锁中...'.tr);
break;
case 0xff:
//
AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误');
showErrorMessage('异常,未知错误');
// showErrorMessage('异常,未知错误');
break;
default:
//

View File

@ -14,7 +14,7 @@ abstract class SenderProtocol extends IOData {
// var uint8View1 = Uint8List(300);
CommandType? commandType; //
final List<int> header = [
final List<int> header = <int>[
0XEF,
0X01,
0XEE,
@ -26,7 +26,7 @@ abstract class SenderProtocol extends IOData {
int identifier =
0x20; // 4 4 1 01AES1282SM43SM4
List<int>? commandData = []; //
List<int>? commandData = <int>[]; //
// final int? tail = 0xFF; // CRC 2
SenderProtocol(this.commandType) {
@ -42,7 +42,7 @@ abstract class SenderProtocol extends IOData {
//TODO:
List<int> packageData() {
commandData = messageDetail();
List<int> commandList = [];
List<int> commandList = <int>[];
//
commandList.addAll(header);
@ -78,7 +78,7 @@ abstract class SenderProtocol extends IOData {
commandList.addAll(commandData!); //
//
var mcrc = crc_16(commandList);
int mcrc = crc_16(commandList);
double mcrcDouble = mcrc / 256;
int mcrcDouble1 = mcrcDouble.toInt();
int mcrcDouble2 = mcrc % 256;
@ -94,7 +94,7 @@ abstract class SenderProtocol extends IOData {
//TODO:
int dataSourceLength() => commandData!.length;
var crcTable = [
List<int> crcTable = <int>[
0x0000,
0x1021,
0x2042,
@ -355,9 +355,9 @@ abstract class SenderProtocol extends IOData {
int crc_16(buffer) {
var len = buffer.length;
var value_ = 0x0000; //0xa635; //CRC类型设定
var tmp;
for (var i = 0; i < buffer.length; i++) {
int value_ = 0x0000; //0xa635; //CRC类型设定
int tmp;
for (int i = 0; i < buffer.length; i++) {
tmp = reverse8(buffer[i]);
value_ =
((value_ << 8) ^ crcTable[((value_ >> 8) ^ tmp) & 0xFF]) & 0xFFFF;
@ -367,8 +367,8 @@ abstract class SenderProtocol extends IOData {
}
int reverse8(data) {
var i;
var temp = 0;
int i;
int temp = 0;
for (i = 0; i < 8; i++) {
//
temp |= ((data >> i) & 0x01) << (7 - i);
@ -377,8 +377,8 @@ abstract class SenderProtocol extends IOData {
}
int reverse16(data) {
var i;
var temp = 0;
int i;
int temp = 0;
for (i = 0; i < 16; i++) {
//
temp |= ((data >> i) & 0x0001) << (15 - i);

View File

@ -10,14 +10,6 @@ extension Extension on DataChannel {
}
class EventSendModel {
List<int> data = [];
String? topic = '';
DataChannel? sendChannel;
String? deviceId;
Uuid? serviceId;
Uuid? characteristicId;
bool? allowLongWrite = false;
EventSendModel(
{required this.data,
@ -27,31 +19,39 @@ class EventSendModel {
this.serviceId,
this.characteristicId,
this.allowLongWrite});
List<int> data = [];
String? topic = '';
DataChannel? sendChannel;
String? deviceId;
Uuid? serviceId;
Uuid? characteristicId;
bool? allowLongWrite = false;
}
///
class EventReceiveModel {
EventReceiveModel({required this.data, this.sendChannel, this.tag});
dynamic data;
String? tag = '';
DataChannel? sendChannel;
EventReceiveModel({required this.data, this.sendChannel, this.tag});
}
///
class EventParseModel {
EventParseModel({required this.type, required this.data, this.commandIndex});
int? type;
int? commandIndex;
dynamic data;
EventParseModel({required this.type, required this.data, this.commandIndex});
}
///debug info model
class StateModel {
StateModel({this.title = '', this.subTitle = '', this.result = false});
final String title;
final String subTitle;
final bool result;
StateModel({this.title = '', this.subTitle = '', this.result = false});
}

View File

@ -51,7 +51,7 @@ int _hexToInt(String hex) {
// a..f
val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)));
} else {
throw FormatException("Invalid hexadecimal value");
throw const FormatException('Invalid hexadecimal value');
}
}
return val;
@ -74,13 +74,13 @@ List<int> getFixedLengthList(List<int> data, int length) {
//int ---> hex (6,0x000001 0x001234, 0xefab23)
String intToFormatHex(int num, int length) {
final String hexString = num.toRadixString(16);
final String formatString = hexString.padLeft(length, "0");
final String formatString = hexString.padLeft(length, '0');
return formatString;
}
String uint8ToHex(Uint8List byteArr) {
if (byteArr.isEmpty) {
return "";
return '';
}
final Uint8List result = Uint8List(byteArr.length << 1);
final List<String> hexTable = <String>[

View File

@ -8,8 +8,10 @@ class ECFieldElementFp {
///
bool equals(ECFieldElementFp other) {
if (other == this) return true;
return (q == other.q && x == other.x);
if (other == this) {
return true;
}
return q == other.q && x == other.x;
}
///

View File

@ -3,41 +3,41 @@ import 'dart:convert';
class SMUtils{
static int leftShift(int x, int n){
int s = n & 31;
final int s = n & 31;
x = (x & 0xFFFFFFFF).toSigned(32);
return (((x << s) | ((x & 0xFFFFFFFF) >> (32 - s))) & 0xFFFFFFFF).toSigned(32);
}
static int rightShift(int x, int n) {
int s = n & 31;
final int s = n & 31;
x = (x & 0xFFFFFFFF).toSigned(32);
return ((x >> s) | ((x << (32 - s)) & 0xFFFFFFFF)).toSigned(32);
}
static String bytesToHexString(List<int> bytes) {
final buffer = StringBuffer();
for (final byte in bytes) {
final StringBuffer buffer = StringBuffer();
for (final int byte in bytes) {
buffer.write(byte.toRadixString(16).padLeft(2, '0'));
}
return buffer.toString();
}
static List<int> hexStringToBytes(String hexString) {
final length = hexString.length ~/ 2;
final bytes = List<int>.filled(length, 0);
final int length = hexString.length ~/ 2;
final List<int> bytes = List<int>.filled(length, 0);
for (int i = 0; i < length; i++) {
final byteString = hexString.substring(i * 2, i * 2 + 2);
final String byteString = hexString.substring(i * 2, i * 2 + 2);
bytes[i] = int.parse(byteString, radix: 16);
}
return bytes;
}
static String utf8ToHexString(String input) {
List<int> utf8Encoded = utf8.encode(input);
final List<int> utf8Encoded = utf8.encode(input);
// 16
StringBuffer hexChars = StringBuffer();
final StringBuffer hexChars = StringBuffer();
for (int i = 0; i < utf8Encoded.length; i++) {
int bite = utf8Encoded[i];
final int bite = utf8Encoded[i];
hexChars.write((bite >> 4).toRadixString(16));
hexChars.write((bite & 0x0f).toRadixString(16));
}

View File

@ -90,7 +90,7 @@ class BaseProvider extends GetConnect with Api {
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
break;
case 500:
EasyLoading.showToast('服务器错误', duration: 2000.milliseconds);
// EasyLoading.showToast('服务器错误', duration: 2000.milliseconds);
break;
case 421:
case 422:
@ -102,11 +102,11 @@ class BaseProvider extends GetConnect with Api {
// Toast.show(msg: "用户不存在");
// break;
case 10001:
EasyLoading.showToast('数据不存在', duration: 2000.milliseconds);
EasyLoading.showToast('数据不存在'.tr, duration: 2000.milliseconds);
break;
case 434: //
ShowTipView()
.showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '确定');
.showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '');
break;
}
}

View File

@ -1,5 +1,7 @@
import 'package:get/get.dart';
import 'dart:async';
import 'package:get/get.dart';
import 'package:get/get_connect/http/src/request/request.dart';
import '../tools/manager/client_manager.dart';

View File

@ -47,7 +47,7 @@ class Header extends StatelessWidget {
vertical: 4.0,
),
child: Text(
'今天',
'今天'.tr,
style: TextStyle(
color: Colors.black,
fontSize: 24.sp,

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
@ -103,7 +104,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
void initState() {
super.initState();
final monthPageIndex = widget.preloadMonthViewAmount ~/ 2;
final int monthPageIndex = widget.preloadMonthViewAmount ~/ 2;
_monthViewCurrentPage = ValueNotifier(monthPageIndex);
@ -111,7 +112,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
initialPage: monthPageIndex,
);
final weekPageIndex = widget.preloadWeekViewAmount ~/ 2;
final int weekPageIndex = widget.preloadWeekViewAmount ~/ 2;
_weekPageController = PageController(
initialPage: weekPageIndex,
@ -130,7 +131,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
_monthRangeList = List.generate(
widget.preloadMonthViewAmount,
(index) => ViewRange.generateDates(
(int index) => ViewRange.generateDates(
_todayDate!,
_todayDate!.month + (index - _monthPageController!.initialPage),
widget.weeksInMonthViewAmount,
@ -150,19 +151,19 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
_weekPageController!.jumpToPage(widget.preloadWeekViewAmount ~/ 2);
});
if (widget.startWeekDay != null && widget.startWeekDay! < 7) {
final time = _controller.value.subtract(
final DateTime time = _controller.value.subtract(
Duration(days: _controller.value.weekday - widget.startWeekDay!),
);
final list = List<DateTime>.generate(
final List<DateTime> list = List<DateTime>.generate(
8,
(index) => time.add(Duration(days: index * 1)),
(int index) => time.add(Duration(days: index * 1)),
).toList();
// _weekNames = List<String>.generate(7, (index) {
// return DateFormat("EEEE").format(list[index]).split('').first;
// }
// );
//by DaisyWu
_weekNames = List<String>.generate(7, (index) {
_weekNames = List<String>.generate(7, (int index) {
String fullWeekName =
DateFormat.E('zh_CN').format(list[index]); //
return fullWeekName
@ -173,23 +174,23 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final ThemeData theme = Theme.of(context);
return Material(
color: Colors.transparent,
child: DefaultTextStyle.merge(
style: theme.textTheme.bodyMedium,
child: GestureDetector(
onVerticalDragStart: (details) {
onVerticalDragStart: (DragStartDetails details) {
_captureOffset = details.globalPosition;
},
onVerticalDragUpdate: (details) {
final moveOffset = details.globalPosition;
final diffY = moveOffset.dy - _captureOffset!.dy;
onVerticalDragUpdate: (DragUpdateDetails details) {
final Offset moveOffset = details.globalPosition;
final double diffY = moveOffset.dy - _captureOffset!.dy;
_animationController.value =
_animationValue + diffY / (widget.weekLineHeight * 5);
},
onVerticalDragEnd: (details) => _handleFinishDrag(),
onVerticalDragEnd: (DragEndDetails details) => _handleFinishDrag(),
onVerticalDragCancel: _handleFinishDrag,
child: Container(
color: Colors.transparent,
@ -197,10 +198,10 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
ValueListenableBuilder<int>(
valueListenable: _monthViewCurrentPage,
builder: (_, value, __) {
builder: (_, int value, __) {
return Header(
monthDate:
_monthRangeList[_monthViewCurrentPage.value].firstDay,
@ -217,12 +218,12 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
keepLineSize: widget.keepLineSize,
weekNames: _weekNames != null
? _weekNames!
: const <String>['', '', '', '', '', '', ''],
: <String>['简写周'.tr, '简写周'.tr, '简写周'.tr, '简写周'.tr, '简写周'.tr, '简写周'.tr, '简写周'.tr],
),
AnimatedBuilder(
animation: _animationController,
builder: (_, __) {
final height = Tween<double>(
final double height = Tween<double>(
begin: widget.weekLineHeight,
end:
widget.weekLineHeight * widget.weeksInMonthViewAmount,
@ -231,12 +232,12 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
height: height,
child: ValueListenableBuilder<DateTime>(
valueListenable: _controller,
builder: (_, selectedDate, __) {
builder: (_, DateTime selectedDate, __) {
AppLog.log('****selectedDate: $selectedDate');
eventBus.fire(DoorLockLogListRefreshUI(selectedDate));
return Stack(
alignment: Alignment.center,
children: [
children: <Widget>[
IgnorePointer(
ignoring: _animationController.value == 0.0,
child: Opacity(
@ -245,7 +246,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
end: 1.0,
).evaluate(_animationController),
child: PageView.builder(
onPageChanged: (pageIndex) {
onPageChanged: (int pageIndex) {
if (widget.onHorizontalDrag != null) {
widget.onHorizontalDrag!(
_monthRangeList[pageIndex].firstDay,
@ -258,7 +259,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
? const AlwaysScrollableScrollPhysics()
: const NeverScrollableScrollPhysics(),
itemCount: _monthRangeList.length,
itemBuilder: (_, pageIndex) {
itemBuilder: (_, int pageIndex) {
return MonthView(
innerDot: widget.innerDot,
monthView: _monthRangeList[pageIndex],
@ -278,12 +279,12 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
),
ValueListenableBuilder<int>(
valueListenable: _monthViewCurrentPage,
builder: (_, pageIndex, __) {
final index = selectedDate.findWeekIndex(
builder: (_, int pageIndex, __) {
final int index = selectedDate.findWeekIndex(
_monthRangeList[_monthViewCurrentPage.value]
.dates,
);
final offset = index /
final double offset = index /
(widget.weeksInMonthViewAmount - 1) *
2 -
1.0;
@ -300,10 +301,10 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
child: SizedBox(
height: widget.weekLineHeight,
child: PageView.builder(
onPageChanged: (indexPage) {
final pageIndex =
onPageChanged: (int indexPage) {
final int pageIndex =
_monthRangeList.indexWhere(
(index) =>
(ViewRange index) =>
index.firstDay.month ==
_weekRangeList[indexPage]
.first
@ -323,7 +324,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
controller: _weekPageController,
itemCount: _weekRangeList.length,
physics: _closeMonthScroll(),
itemBuilder: (context, index) {
itemBuilder: (BuildContext context, int index) {
return WeekView(
innerDot: widget.innerDot,
dates: _weekRangeList[index],
@ -384,7 +385,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
_handleDateChanged(date);
_monthViewCurrentPage.value = _monthRangeList
.lastIndexWhere((monthRange) => monthRange.dates.contains(date));
.lastIndexWhere((ViewRange monthRange) => monthRange.dates.contains(date));
}
void _handleDateChanged(DateTime date) {
@ -411,10 +412,10 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
}
ScrollPhysics _closeMonthScroll() {
if ((_monthViewCurrentPage.value ==
if (_monthViewCurrentPage.value ==
(widget.preloadMonthViewAmount ~/ 2) + 3 ||
_monthViewCurrentPage.value ==
(widget.preloadMonthViewAmount ~/ 2) - 3)) {
(widget.preloadMonthViewAmount ~/ 2) - 3) {
return const NeverScrollableScrollPhysics();
} else {
return const AlwaysScrollableScrollPhysics();

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
import 'package:star_lock/app_settings/app_settings.dart';

View File

@ -4,6 +4,18 @@
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
class DateItemModel {
DateItemModel(
this.year, this.month, this.day, this.hour, this.minute, this.second);
DateItemModel.parse(DateMode dateMode) {
year = DateModeMap[dateMode]!.contains('');
month = DateModeMap[dateMode]!.contains('');
day = DateModeMap[dateMode]!.contains('');
hour = DateModeMap[dateMode]!.contains('');
minute = DateModeMap[dateMode]!.contains('');
second = DateModeMap[dateMode]!.contains('');
}
late bool year;
late bool month;
late bool day;
@ -11,34 +23,34 @@ class DateItemModel {
late bool minute;
late bool second;
DateItemModel(
this.year, this.month, this.day, this.hour, this.minute, this.second);
DateItemModel.parse(DateMode dateMode) {
this.year = DateModeMap[dateMode]!.contains('');
this.month = DateModeMap[dateMode]!.contains('');
this.day = DateModeMap[dateMode]!.contains('');
this.hour = DateModeMap[dateMode]!.contains('');
this.minute = DateModeMap[dateMode]!.contains('');
this.second = DateModeMap[dateMode]!.contains('');
}
// picker
int get length {
int i = 0;
if (this.year) ++i;
if (this.month) ++i;
if (this.day) ++i;
if (this.hour) ++i;
if (this.minute) ++i;
if (this.second) ++i;
if (year) {
++i;
}
if (month) {
++i;
}
if (day) {
++i;
}
if (hour) {
++i;
}
if (minute) {
++i;
}
if (second) {
++i;
}
return i;
}
}
const DateModeMap = {
DateMode.YMDHMS: "年月日时分秒",
DateMode.YMDHMS: '年月日时分秒',
DateMode.YMDHM: '年月日时分',
DateMode.YMDH: '年月日时',
DateMode.YMD: '年月日',

View File

@ -4,12 +4,12 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_type.dart';
/// item
class DateTimeData {
List _year = [];
List _month = [];
List _day = [];
List _hour = [];
List _minute = [];
List _second = [];
final List _year = [];
final List _month = [];
final List _day = [];
final List _hour = [];
final List _minute = [];
final List _second = [];
List getListByName(DateType type) {
switch (type) {

View File

@ -18,14 +18,43 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_type.dart';
/// {year: 2020, month: 3, day: 4, hour: 0, minute: 0, second: 0}
bool intEmpty(int? value) {
return (value == null || value == 0);
return value == null || value == 0;
}
bool intNotEmpty(int? value) {
return (value != null && value != 0);
return value != null && value != 0;
}
class PDuration {
PDuration(
{this.year = 0,
this.month = 0,
this.day = 0,
this.hour = 0,
this.minute = 0,
this.second = 0});
// 0 null
PDuration.parse(DateTime? dateTime) {
dateTime ??= DateTime.now();
year = dateTime.year;
month = dateTime.month;
day = dateTime.day;
hour = dateTime.hour;
minute = dateTime.minute;
second = dateTime.second;
}
PDuration.now() {
var thisInstant = new DateTime.now();
year = thisInstant.year;
month = thisInstant.month;
day = thisInstant.day;
hour = thisInstant.hour;
minute = thisInstant.minute;
second = thisInstant.second;
}
int? year;
int? month;
int? day;
@ -33,54 +62,25 @@ class PDuration {
int? minute;
int? second;
PDuration(
{this.year: 0,
this.month: 0,
this.day: 0,
this.hour: 0,
this.minute: 0,
this.second: 0});
// 0 null
PDuration.parse(DateTime? dateTime) {
dateTime ??= DateTime.now();
this.year = dateTime.year;
this.month = dateTime.month;
this.day = dateTime.day;
this.hour = dateTime.hour;
this.minute = dateTime.minute;
this.second = dateTime.second;
}
PDuration.now() {
var thisInstant = new DateTime.now();
this.year = thisInstant.year;
this.month = thisInstant.month;
this.day = thisInstant.day;
this.hour = thisInstant.hour;
this.minute = thisInstant.minute;
this.second = thisInstant.second;
}
void setSingle(DateType dateType, var value) {
switch (dateType) {
case DateType.Year:
this.year = value;
year = value;
break;
case DateType.Month:
this.month = value;
month = value;
break;
case DateType.Day:
this.day = value;
day = value;
break;
case DateType.Hour:
this.hour = value;
hour = value;
break;
case DateType.Minute:
this.minute = value;
minute = value;
break;
case DateType.Second:
this.second = value;
second = value;
break;
}
}
@ -89,17 +89,17 @@ class PDuration {
int getSingle(DateType dateType) {
switch (dateType) {
case DateType.Year:
return this.year ?? 0;
return year ?? 0;
case DateType.Month:
return this.month ?? 0;
return month ?? 0;
case DateType.Day:
return this.day ?? 0;
return day ?? 0;
case DateType.Hour:
return this.hour ?? 0;
return hour ?? 0;
case DateType.Minute:
return this.minute ?? 0;
return minute ?? 0;
case DateType.Second:
return this.second ?? 0;
return second ?? 0;
}
}

View File

@ -4,6 +4,23 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_type.dart';
///
class Suffix {
Suffix(
{this.years = '',
this.month = '',
this.days = '',
this.hours = '',
this.minutes = '',
this.seconds = ''});
Suffix.normal() {
years = '';
month = '';
days = '';
hours = '';
minutes = '';
seconds = '';
}
late String years;
late String month;
late String days;
@ -11,37 +28,20 @@ class Suffix {
late String minutes;
late String seconds;
Suffix.normal() {
this.years = '';
this.month = '';
this.days = '';
this.hours = '';
this.minutes = '';
this.seconds = '';
}
Suffix(
{this.years: '',
this.month: '',
this.days: '',
this.hours: '',
this.minutes: '',
this.seconds: ''});
String getSingle(DateType dateType) {
switch (dateType) {
case DateType.Year:
return this.years;
return years;
case DateType.Month:
return this.month;
return month;
case DateType.Day:
return this.days;
return days;
case DateType.Hour:
return this.hours;
return hours;
case DateType.Minute:
return this.minutes;
return minutes;
case DateType.Second:
return this.seconds;
return seconds;
}
}
}

View File

@ -71,7 +71,7 @@ class TimeUtils {
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
return (v < 10) ? '0$v' : '$v';
}

View File

@ -282,7 +282,7 @@ class PermissionDialog {
//
static Future<bool> request(Permission permission, [String? content]) async {
AppLog.log('context:${content}');
AppLog.log('context:$content');
if (Get.context == null) {
return false;
}