初始化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hgdj/hj_model/mine/official_list_item_model.dart';
|
||||
import 'package:hgdj/hj_utils/api_service/mine_service.dart';
|
||||
|
||||
class MineDriveLogic extends GetxController {
|
||||
/// null 表示未加载(loading 态),非 null 表示已加载(可能为空)
|
||||
List<OfficialListItemModel>? allList;
|
||||
List<OfficialListItemModel> groupList = [];
|
||||
List<OfficialListItemModel> officialList = [];
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
loadData();
|
||||
}
|
||||
|
||||
Future<void> loadData() async {
|
||||
final list = await MineService.getOfficialLists() ?? [];
|
||||
allList = list;
|
||||
// position == 2 归商务合作,其余归官方社群
|
||||
officialList = list.where((e) => e.position == 2).toList();
|
||||
groupList = list.where((e) => e.position != 2).toList();
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hgdj/assets_tool/app_colors.dart';
|
||||
import 'package:hgdj/hj_utils/screen.dart';
|
||||
import 'package:hgdj/hj_utils/text_util.dart';
|
||||
|
||||
import '../../../hj_model/mine/official_list_item_model.dart';
|
||||
import '../../../routers/jump_router.dart';
|
||||
import '../../../tools_base/loading/loading_center_widget.dart';
|
||||
import '../../../tools_base/widget/net_image_widget.dart';
|
||||
import 'mine_drive_logic.dart';
|
||||
|
||||
class MineDrivePage extends StatelessWidget {
|
||||
const MineDrivePage({super.key});
|
||||
|
||||
static const _titleStyle =
|
||||
TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600);
|
||||
static const _subtitleStyle =
|
||||
TextStyle(color: Color(0xff525252), fontSize: 12);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('加群开车')),
|
||||
body: GetBuilder<MineDriveLogic>(
|
||||
init: MineDriveLogic(),
|
||||
builder: (controller) {
|
||||
if (controller.allList == null) return const LoadingCenterWidget();
|
||||
if (controller.allList!.isEmpty) {
|
||||
return CErrorWidget(retryOnTap: controller.loadData);
|
||||
}
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (controller.groupList.isNotEmpty)
|
||||
_buildSection(
|
||||
title: '官方社群',
|
||||
subtitle: '一起看片一起分享心得',
|
||||
list: controller.groupList),
|
||||
if (controller.officialList.isNotEmpty)
|
||||
_buildSection(
|
||||
title: '商务合作',
|
||||
subtitle: '代理合作/商务合作',
|
||||
list: controller.officialList),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 一个分组区块:标题 + 副标题 + 列表卡片
|
||||
Widget _buildSection({
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required List<OfficialListItemModel> list,
|
||||
}) {
|
||||
return SliverToBoxAdapter(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
18.sizeBoxH,
|
||||
Text(title, style: _titleStyle),
|
||||
6.sizeBoxH,
|
||||
Text(subtitle, style: _subtitleStyle),
|
||||
12.sizeBoxH,
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: .05),
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
),
|
||||
child: Column(children: list.map(_buildItem).toList()),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 单条社群/合作项
|
||||
Widget _buildItem(OfficialListItemModel item) {
|
||||
return InkWell(
|
||||
enableFeedback: false,
|
||||
onTap: () => launchUrlToWeb(item.officialUrl ?? ''),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
height: 80,
|
||||
alignment: Alignment.center,
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImageLoader(
|
||||
imageUrl: item.officialImg ?? '', width: 40, height: 40),
|
||||
12.sizeBoxW,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.officialName ?? '',
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontSize: 14, height: 1.1),
|
||||
),
|
||||
if (TextUtil.isNotEmpty(item.officialDesc)) ...[
|
||||
6.sizeBoxH,
|
||||
Text(
|
||||
item.officialDesc ?? '',
|
||||
style: const TextStyle(
|
||||
color: Color(0xff525252), fontSize: 12, height: 1.1),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
height: 26,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.actionRed,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
child: const Text(
|
||||
'立即加入',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user