12 changed files with 406 additions and 165 deletions
Unified View
Diff Options
-
BINassets/images/banner.png
-
BINassets/images/event.png
-
2lib/generated/assets.dart
-
4lib/pages/home/home_page.dart
-
208lib/pages/home/recommend_tab.dart
-
70lib/pages/home/recommend_window.dart
-
27lib/pages/home/send_timeline.dart
-
26lib/pages/home/timeline_info.dart
-
28lib/pages/home/timeline_item.dart
-
144lib/pages/home/timeline_page.dart
-
23lib/pages/home/timeline_window.dart
-
39lib/pages/main/main_page.dart
@ -0,0 +1,144 @@ |
|||||
|
import 'package:dating_touchme_app/extension/ex_widget.dart'; |
||||
|
import 'package:dating_touchme_app/generated/assets.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/recommend_window.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/send_timeline.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/timeline_window.dart'; |
||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
import 'package:dating_touchme_app/controller/home/home_controller.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/recommend_tab.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/nearby_tab.dart'; |
||||
|
|
||||
|
class TimelinePage extends StatefulWidget { |
||||
|
const TimelinePage({super.key}); |
||||
|
|
||||
|
@override |
||||
|
State<TimelinePage> createState() => _TimelinePageState(); |
||||
|
} |
||||
|
|
||||
|
class _TimelinePageState extends State<TimelinePage> |
||||
|
with AutomaticKeepAliveClientMixin { |
||||
|
@override |
||||
|
void initState() { |
||||
|
super.initState(); |
||||
|
// 确保 HomeController 已注册 |
||||
|
if (!Get.isRegistered<HomeController>()) { |
||||
|
Get.put(HomeController()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
super.build(context); |
||||
|
return GetBuilder<HomeController>( |
||||
|
builder: (controller) { |
||||
|
return Stack( |
||||
|
children: [ |
||||
|
// 背景图 - 覆盖整个屏幕包括状态栏和导航栏 |
||||
|
Image.asset( |
||||
|
Assets.imagesBgInformation, |
||||
|
fit: BoxFit.cover, |
||||
|
width: double.infinity, |
||||
|
height: double.infinity, |
||||
|
), |
||||
|
Scaffold( |
||||
|
backgroundColor: Colors.transparent, |
||||
|
appBar: _buildAppBar(controller), |
||||
|
body: Stack( |
||||
|
children: [ |
||||
|
Obx(() { |
||||
|
// 使用 IndexedStack 保持两个列表的状态,根据当前选中的标签显示对应的列表 |
||||
|
return IndexedStack( |
||||
|
index: controller.topTab.value, |
||||
|
children: const [ |
||||
|
// // 推荐列表 |
||||
|
// RecommendWindow(), |
||||
|
// 同城列表 |
||||
|
TimelineWindow(), |
||||
|
], |
||||
|
); |
||||
|
}), |
||||
|
Positioned( |
||||
|
bottom: 44.w, |
||||
|
right: 3.w, |
||||
|
child: Image.asset( |
||||
|
Assets.imagesPublish, |
||||
|
width: 60.w, |
||||
|
).onTap((){ |
||||
|
Get.to(() => SendTimeline()); |
||||
|
}), |
||||
|
) |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
], |
||||
|
); |
||||
|
}, |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
PreferredSizeWidget _buildAppBar(HomeController controller) { |
||||
|
return AppBar( |
||||
|
backgroundColor: Colors.transparent, |
||||
|
elevation: 0, |
||||
|
centerTitle: true, |
||||
|
toolbarHeight: 56, |
||||
|
titleSpacing: 0, |
||||
|
title: Row( |
||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||
|
mainAxisSize: MainAxisSize.min, |
||||
|
children: [ |
||||
|
// _buildTabButton(title: '推荐', index: 0, controller: controller), |
||||
|
// const SizedBox(width: 28), |
||||
|
_buildTabButton(title: '广场', index: 0, controller: controller), |
||||
|
], |
||||
|
), |
||||
|
bottom: const PreferredSize( |
||||
|
preferredSize: Size.fromHeight(4), |
||||
|
child: SizedBox(height: 4), |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
Widget _buildTabButton({ |
||||
|
required String title, |
||||
|
required int index, |
||||
|
required HomeController controller, |
||||
|
}) { |
||||
|
final bool selected = controller.topTab.value == index; |
||||
|
return GestureDetector( |
||||
|
onTap: () { |
||||
|
print('Tab $index clicked'); |
||||
|
if (controller.topTab.value != index) { |
||||
|
controller.setTopTab(index); |
||||
|
// 确保状态更新后刷新UI |
||||
|
controller.update(); |
||||
|
} |
||||
|
}, |
||||
|
child: Column( |
||||
|
mainAxisSize: MainAxisSize.min, |
||||
|
crossAxisAlignment: CrossAxisAlignment.center, |
||||
|
children: [ |
||||
|
Text( |
||||
|
title, |
||||
|
style: TextStyle( |
||||
|
fontSize: selected ? 19 : 17, |
||||
|
fontWeight: selected ? FontWeight.w700 : FontWeight.w400, |
||||
|
color: selected |
||||
|
? const Color(0xFF333333) |
||||
|
: const Color(0xFF999999), |
||||
|
), |
||||
|
), |
||||
|
const SizedBox(height: 6), |
||||
|
selected |
||||
|
? Image.asset(Assets.imagesTabChangeIcon, width: 32, height: 8) |
||||
|
: const SizedBox(height: 8), |
||||
|
], |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
bool get wantKeepAlive => true; |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save