From 0ab9b5f03a239f215ed7d7053498acc1b8af8eda Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 4 Aug 2025 15:54:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ios=E5=92=8Candroid?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lock_voice_setting_page.dart | 210 +++++++++--------- 1 file changed, 101 insertions(+), 109 deletions(-) diff --git a/lib/mine/addLock/lock_voice_setting/lock_voice_setting_page.dart b/lib/mine/addLock/lock_voice_setting/lock_voice_setting_page.dart index e4fc66ff..ed5e0ec5 100644 --- a/lib/mine/addLock/lock_voice_setting/lock_voice_setting_page.dart +++ b/lib/mine/addLock/lock_voice_setting/lock_voice_setting_page.dart @@ -37,18 +37,29 @@ class _LockVoiceSettingState extends State { barTitle: '锁语音包设置'.tr, haveBack: false, haveOtherLeftWidget: true, - leftWidget: TextButton( - onPressed: () { - eventBus - .fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); - Get.offAllNamed(Routers.starLockMain); - }, - child: Text( - '跳过'.tr, - style: TextStyle( - color: Colors.white, - fontSize: 24.sp, - fontWeight: FontWeight.w500, + leftWidget: Container( + width: 60.w, // 手动扩大leading区域宽度,防止内容换行 + child: TextButton( + onPressed: () { + eventBus + .fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); + Get.offAllNamed(Routers.starLockMain); + }, + style: TextButton.styleFrom( + padding: EdgeInsets.symmetric(horizontal: 4), // 减少两侧空白 + minimumSize: Size.zero, // 避免最小尺寸影响 + tapTargetSize: MaterialTapTargetSize.shrinkWrap, // 紧凑布局 + ), + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + '跳过'.tr, + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, // 减小字体,防止换行 + fontWeight: FontWeight.w500, + ), + ), ), ), ), @@ -67,111 +78,92 @@ class _LockVoiceSettingState extends State { ), ], ), - body: _buildBody(), - ), - ); - } - - Widget _buildBody() { - return Obx( - () => SingleChildScrollView( - child: Column( - children: [ - Container( - width: 1.sw, - decoration: BoxDecoration(color: Colors.white), - child: ListView.builder( - itemCount: state.soundTypeList.length, - itemBuilder: (BuildContext context, int index) { - // 判断是否是最后一个元素(索引等于 itemCount - 1) - final isLastItem = index == state.soundTypeList.length - 1; - - // 获取当前平台数据(假设 platFormSet 是 RxList) - final platform = state.soundTypeList.value[index]; - return CommonItem( - leftTitel: state.soundTypeList.value[index], - rightTitle: '', - isHaveLine: !isLastItem, - // 最后一个元素不显示分割线(取反) - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: Radio( - // Radio 的值:使用平台的唯一标识(如 id) - value: platform, - // 当前选中的值:与 selectPlatFormIndex 关联的 id - groupValue: state.soundTypeList - .value[state.selectSoundTypeIndex.value], - // 选中颜色(可选,默认主题色) - activeColor: AppColors.mainColor, - // 点击 Radio 时回调(更新选中索引) - onChanged: (value) { - if (value != null) { - setState(() { - // 找到当前选中平台的索引(根据 id 匹配) - final newIndex = state.soundTypeList.value - .indexWhere((p) => p == value); - if (newIndex != -1) { - state.selectSoundTypeIndex.value = newIndex; + body: Obx( + () => ListView( + padding: EdgeInsets.zero, + children: [ + // 语音类型选择区 + Container( + width: 1.sw, + color: Colors.white, + child: Column( + children: List.generate( + state.soundTypeList.length, + (index) { + final isLastItem = + index == state.soundTypeList.length - 1; + final soundType = state.soundTypeList.value[index]; + return CommonItem( + leftTitel: soundType, + rightTitle: '', + isHaveLine: !isLastItem, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: Radio( + value: soundType, + groupValue: state.soundTypeList + .value[state.selectSoundTypeIndex.value], + activeColor: AppColors.mainColor, + onChanged: (value) { + if (value != null) { + final newIndex = state.soundTypeList.value + .indexWhere((p) => p == value); + if (newIndex != -1) { + state.selectSoundTypeIndex.value = newIndex; + } } - }); - } - }, - ), - action: () { - setState(() { - state.selectSoundTypeIndex.value = index; - }); + }, + ), + action: () { + state.selectSoundTypeIndex.value = index; + }, + ); }, - ); - }, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), + ), + ), ), - ), - SizedBox( - height: 8.h, - ), - Column( - children: _buildList(), - ), - ], + SizedBox( + height: 8.h, + ), + // 语言包列表区 + Container( + color: Colors.transparent, + child: Column( + children: List.generate( + state.languages.length, + (index) { + final item = state.languages[index]; + return CommonItem( + leftTitel: item.langText, + rightTitle: '', + isHaveLine: true, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: + state.selectPassthroughListIndex.value == index + ? Image( + image: const AssetImage( + 'images/icon_item_checked.png'), + width: 30.w, + height: 30.w, + fit: BoxFit.contain, + ) + : Container(), + action: () { + state.selectPassthroughListIndex.value = index; + }, + ); + }, + ), + ), + ), + ], + ), ), ), ); } - List _buildList() { - final appLocalLanguages = state.languages; - return List.generate( - appLocalLanguages.length, - (index) => _buildItem( - appLocalLanguages[index], - index, - ), - ); - } - - _buildItem(PassthroughItem passthroughItem, index) { - return CommonItem( - leftTitel: passthroughItem.langText, - rightTitle: '', - isHaveLine: true, - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: state.selectPassthroughListIndex.value == index - ? Image( - image: const AssetImage('images/icon_item_checked.png'), - width: 30.w, - height: 30.w, - fit: BoxFit.contain, - ) - : Container(), - action: () { - state.selectPassthroughListIndex.value = index; - }, - ); - } - @override void dispose() { // TODO: implement dispose