fix:调整ios和android页面不一致的问题
This commit is contained in:
parent
79948ff405
commit
0ab9b5f03a
@ -37,18 +37,29 @@ class _LockVoiceSettingState extends State<LockVoiceSetting> {
|
|||||||
barTitle: '锁语音包设置'.tr,
|
barTitle: '锁语音包设置'.tr,
|
||||||
haveBack: false,
|
haveBack: false,
|
||||||
haveOtherLeftWidget: true,
|
haveOtherLeftWidget: true,
|
||||||
leftWidget: TextButton(
|
leftWidget: Container(
|
||||||
onPressed: () {
|
width: 60.w, // 手动扩大leading区域宽度,防止内容换行
|
||||||
eventBus
|
child: TextButton(
|
||||||
.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
|
onPressed: () {
|
||||||
Get.offAllNamed(Routers.starLockMain);
|
eventBus
|
||||||
},
|
.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
|
||||||
child: Text(
|
Get.offAllNamed(Routers.starLockMain);
|
||||||
'跳过'.tr,
|
},
|
||||||
style: TextStyle(
|
style: TextButton.styleFrom(
|
||||||
color: Colors.white,
|
padding: EdgeInsets.symmetric(horizontal: 4), // 减少两侧空白
|
||||||
fontSize: 24.sp,
|
minimumSize: Size.zero, // 避免最小尺寸影响
|
||||||
fontWeight: FontWeight.w500,
|
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<LockVoiceSetting> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: _buildBody(),
|
body: Obx(
|
||||||
),
|
() => ListView(
|
||||||
);
|
padding: EdgeInsets.zero,
|
||||||
}
|
children: [
|
||||||
|
// 语音类型选择区
|
||||||
Widget _buildBody() {
|
Container(
|
||||||
return Obx(
|
width: 1.sw,
|
||||||
() => SingleChildScrollView(
|
color: Colors.white,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: List.generate(
|
||||||
Container(
|
state.soundTypeList.length,
|
||||||
width: 1.sw,
|
(index) {
|
||||||
decoration: BoxDecoration(color: Colors.white),
|
final isLastItem =
|
||||||
child: ListView.builder(
|
index == state.soundTypeList.length - 1;
|
||||||
itemCount: state.soundTypeList.length,
|
final soundType = state.soundTypeList.value[index];
|
||||||
itemBuilder: (BuildContext context, int index) {
|
return CommonItem(
|
||||||
// 判断是否是最后一个元素(索引等于 itemCount - 1)
|
leftTitel: soundType,
|
||||||
final isLastItem = index == state.soundTypeList.length - 1;
|
rightTitle: '',
|
||||||
|
isHaveLine: !isLastItem,
|
||||||
// 获取当前平台数据(假设 platFormSet 是 RxList<Platform>)
|
isHaveDirection: false,
|
||||||
final platform = state.soundTypeList.value[index];
|
isHaveRightWidget: true,
|
||||||
return CommonItem(
|
rightWidget: Radio<String>(
|
||||||
leftTitel: state.soundTypeList.value[index],
|
value: soundType,
|
||||||
rightTitle: '',
|
groupValue: state.soundTypeList
|
||||||
isHaveLine: !isLastItem,
|
.value[state.selectSoundTypeIndex.value],
|
||||||
// 最后一个元素不显示分割线(取反)
|
activeColor: AppColors.mainColor,
|
||||||
isHaveDirection: false,
|
onChanged: (value) {
|
||||||
isHaveRightWidget: true,
|
if (value != null) {
|
||||||
rightWidget: Radio<String>(
|
final newIndex = state.soundTypeList.value
|
||||||
// Radio 的值:使用平台的唯一标识(如 id)
|
.indexWhere((p) => p == value);
|
||||||
value: platform,
|
if (newIndex != -1) {
|
||||||
// 当前选中的值:与 selectPlatFormIndex 关联的 id
|
state.selectSoundTypeIndex.value = newIndex;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
}
|
),
|
||||||
},
|
action: () {
|
||||||
),
|
state.selectSoundTypeIndex.value = index;
|
||||||
action: () {
|
},
|
||||||
setState(() {
|
);
|
||||||
state.selectSoundTypeIndex.value = index;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
height: 8.h,
|
||||||
height: 8.h,
|
),
|
||||||
),
|
// 语言包列表区
|
||||||
Column(
|
Container(
|
||||||
children: _buildList(),
|
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<Widget> _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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user