feat(mobile-next): 导入官方 openim-flutter-demo 固定基线 3.8.3-patch.3 并完成双构建
- 上游: github.com/OpenIMSDK/openim-flutter-demo tag 3.8.3-patch.3 commit b3dfdb1e8aaeaaf6f0793e10cadd20d5c184a31f - 并行目录 mobile-next/ 原样导入(含 LICENSE),不覆盖现网 mobile/ - 锁定 Flutter 3.24.5 / Dart 3.5.4 / JDK 17 / Gradle 7.6.3 / AGP 7.3.1 - 实测 Android debug 与 release 构建均成功(见 docs/mobile-next-baseline-import.md) - 本提交可单独回退:git revert 1db1229(重写前) Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'unlock_setup_logic.dart';
|
||||
|
||||
class UnlockSetupBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => UnlockSetupLogic());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screen_lock/flutter_screen_lock.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
class UnlockSetupLogic extends GetxController {
|
||||
final passwordEnabled = false.obs;
|
||||
final fingerprintEnabled = false.obs;
|
||||
final gestureEnabled = false.obs;
|
||||
final biometricsEnabled = false.obs;
|
||||
final isSupportedBiometric = false.obs;
|
||||
final canCheckBiometrics = false.obs;
|
||||
String? lockScreenPwd;
|
||||
final auth = LocalAuthentication();
|
||||
late List<BiometricType> availableBiometrics;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
checkingSupported();
|
||||
lockScreenPwd = DataSp.getLockScreenPassword();
|
||||
biometricsEnabled.value = DataSp.isEnabledBiometric() == true;
|
||||
passwordEnabled.value = lockScreenPwd != null;
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void checkingSupported() async {
|
||||
isSupportedBiometric.value = await auth.isDeviceSupported();
|
||||
canCheckBiometrics.value = await auth.canCheckBiometrics;
|
||||
availableBiometrics = await auth.getAvailableBiometrics();
|
||||
|
||||
if (availableBiometrics.isNotEmpty) {}
|
||||
|
||||
if (availableBiometrics.contains(BiometricType.strong) || availableBiometrics.contains(BiometricType.weak)) {}
|
||||
}
|
||||
|
||||
void toggleBiometricLock() async {
|
||||
if (biometricsEnabled.value) {
|
||||
await DataSp.closeBiometric();
|
||||
biometricsEnabled.value = false;
|
||||
} else {
|
||||
final didAuthenticate = await IMUtils.checkingBiometric(auth);
|
||||
if (didAuthenticate) {
|
||||
await DataSp.openBiometric();
|
||||
biometricsEnabled.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void togglePwdLock() {
|
||||
if (passwordEnabled.value) {
|
||||
closePwdLock();
|
||||
} else {
|
||||
openPwdLock();
|
||||
}
|
||||
}
|
||||
|
||||
void closePwdLock() {
|
||||
screenLock(
|
||||
context: Get.context!,
|
||||
correctString: lockScreenPwd!,
|
||||
title: StrRes.plsEnterPwd.toText..style = Styles.ts_FFFFFF_17sp,
|
||||
onUnlocked: () async {
|
||||
await DataSp.clearLockScreenPassword();
|
||||
await DataSp.closeBiometric();
|
||||
passwordEnabled.value = false;
|
||||
biometricsEnabled.value = false;
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void openPwdLock() {
|
||||
final controller = InputController();
|
||||
screenLockCreate(
|
||||
context: Get.context!,
|
||||
inputController: controller,
|
||||
title: StrRes.plsEnterNewPwd.toText..style = Styles.ts_FFFFFF_17sp,
|
||||
confirmTitle: StrRes.plsConfirmNewPwd.toText..style = Styles.ts_FFFFFF_17sp,
|
||||
cancelButton: StrRes.cancel.toText..style = Styles.ts_FFFFFF_17sp,
|
||||
onConfirmed: (matchedText) async {
|
||||
lockScreenPwd = matchedText;
|
||||
await DataSp.putLockScreenPassword(matchedText);
|
||||
passwordEnabled.value = true;
|
||||
Get.back();
|
||||
},
|
||||
footer: TextButton(
|
||||
onPressed: () {
|
||||
controller.unsetConfirmed();
|
||||
},
|
||||
child: StrRes.reset.toText..style = Styles.ts_0089FF_17sp,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
|
||||
import 'unlock_setup_logic.dart';
|
||||
|
||||
class UnlockSetupPage extends StatelessWidget {
|
||||
final logic = Get.find<UnlockSetupLogic>();
|
||||
|
||||
UnlockSetupPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: TitleBar.back(title: StrRes.unlockSettings),
|
||||
backgroundColor: Styles.c_F8F9FA,
|
||||
body: Obx(() => Column(
|
||||
children: [
|
||||
12.verticalSpace,
|
||||
_buildItemView(
|
||||
label: StrRes.password,
|
||||
switchOn: logic.passwordEnabled.value,
|
||||
onChanged: (_) => logic.togglePwdLock(),
|
||||
isTopRadius: true,
|
||||
),
|
||||
if (logic.passwordEnabled.value &&
|
||||
(logic.isSupportedBiometric.value &&
|
||||
logic.canCheckBiometrics.value))
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 26.w, right: 10.w),
|
||||
color: Styles.c_E8EAEF,
|
||||
height: .5,
|
||||
),
|
||||
if (logic.passwordEnabled.value &&
|
||||
(logic.isSupportedBiometric.value &&
|
||||
logic.canCheckBiometrics.value))
|
||||
_buildItemView(
|
||||
label: StrRes.biometrics,
|
||||
switchOn: logic.biometricsEnabled.value,
|
||||
onChanged: (_) => logic.toggleBiometricLock(),
|
||||
isBottomRadius: true,
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemView({
|
||||
required String label,
|
||||
bool isTopRadius = false,
|
||||
bool isBottomRadius = false,
|
||||
bool switchOn = false,
|
||||
ValueChanged<bool>? onChanged,
|
||||
}) =>
|
||||
Container(
|
||||
height: 60.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Styles.c_FFFFFF,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(isTopRadius ? 6.r : 0),
|
||||
topRight: Radius.circular(isTopRadius ? 6.r : 0),
|
||||
bottomRight: Radius.circular(isBottomRadius ? 6.r : 0),
|
||||
bottomLeft: Radius.circular(isBottomRadius ? 6.r : 0),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
label.toText..style = Styles.ts_0C1C33_17sp,
|
||||
const Spacer(),
|
||||
CupertinoSwitch(
|
||||
value: switchOn,
|
||||
activeColor: Styles.c_0089FF,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user