release
This commit is contained in:
@@ -118,7 +118,7 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'填写投票凭证',
|
||||
'填写 投票凭证',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
IconButton(
|
||||
@@ -127,7 +127,14 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// const SizedBox(height: 8),
|
||||
// 副标题
|
||||
const Text(
|
||||
'微信号或手机号或邮箱作为投票凭证,\n任何人都可以填写,限时开放投票,\n投票凭证仅用于投票,不会泄露隐私.\n结束后删除会所有凭证,仅保留投票结果',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
@@ -135,7 +142,7 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
TextFormField(
|
||||
controller: _usernameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '投票凭证',
|
||||
labelText: '点击填写',
|
||||
hintText: '手机号/邮箱/微信号',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import 'dart:io' as io;
|
||||
|
||||
class PopMenu extends StatelessWidget {
|
||||
final VoidCallback? onRefresh;
|
||||
@@ -44,32 +45,38 @@ class PopMenu extends StatelessWidget {
|
||||
|
||||
static Future<void> toggleScreenWake(BuildContext context) async {
|
||||
try {
|
||||
// 检查当前状态
|
||||
final bool isEnabled = await WakelockPlus.enabled;
|
||||
// 使用 io.Platform 检测平台
|
||||
final String osName = io.Platform.operatingSystem;
|
||||
final String osVersion = io.Platform.operatingSystemVersion;
|
||||
print('Current platform: $osName, version: $osVersion');
|
||||
|
||||
// 直接尝试启用屏幕常亮
|
||||
await WakelockPlus.enable();
|
||||
|
||||
// 切换状态
|
||||
if (isEnabled) {
|
||||
await WakelockPlus.disable();
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('屏幕常亮已关闭')));
|
||||
}
|
||||
} else {
|
||||
await WakelockPlus.enable();
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启')));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启')));
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
print('WakelockPlus error: $e');
|
||||
print('Stack trace: $stackTrace');
|
||||
if (context.mounted) {
|
||||
// 检查错误类型,判断是否是设备不支持
|
||||
String errorMessage;
|
||||
if (e.toString().contains('not supported') ||
|
||||
e.toString().contains('unsupported') ||
|
||||
e.toString().contains('不支持')) {
|
||||
errorMessage = '该设备不支持屏幕常亮功能';
|
||||
} else {
|
||||
errorMessage = '屏幕常亮功能异常: $e';
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text('该设备不支持屏幕常亮功能'),
|
||||
content: Text(errorMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
@@ -134,9 +141,11 @@ class PopMenu extends StatelessWidget {
|
||||
Icons.screen_lock_rotation,
|
||||
() => toggleScreenWake(context),
|
||||
),
|
||||
_buildBottomSheetItem(context, '夜间模式', Icons.dark_mode, onDarkMode),
|
||||
_buildBottomSheetItem(context, '取消', Icons.settings, onSettings),
|
||||
const SizedBox(height: 20),
|
||||
_buildBottomSheetItem(context, '设置', Icons.settings, onSettings),
|
||||
_buildBottomSheetItem(context, '返回桌面', Icons.exit_to_app, () {
|
||||
SystemNavigator.pop();
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user