|
@@ -1,4 +1,5 @@
|
|
|
|
|
|
|
|
+import 'package:cs_resources/generated/assets.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
@@ -15,7 +16,9 @@ import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
import '../../router/page/community_page_router.dart';
|
|
import '../../router/page/community_page_router.dart';
|
|
|
|
+import '../newsfeed/newsfeed_tabs.dart';
|
|
import 'community_vm.dart';
|
|
import 'community_vm.dart';
|
|
|
|
+import 'customSilverHeaderTabs.dart';
|
|
|
|
|
|
@RoutePage()
|
|
@RoutePage()
|
|
class CommunityPage extends HookConsumerWidget {
|
|
class CommunityPage extends HookConsumerWidget {
|
|
@@ -31,11 +34,95 @@ class CommunityPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @override
|
|
|
|
+ Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
+ final vm = ref.read(communityVmProvider.notifier);
|
|
|
|
+ final stateTabsRouter = ref.watch(communityVmProvider).tabsRouter;
|
|
|
|
+ // final state = ref.watch(communityVmProvider);
|
|
|
|
+ BuildContext contextPage = context;
|
|
|
|
+
|
|
|
|
+ // useEffect((){
|
|
|
|
+ // Log.d("CommunityPage initState");
|
|
|
|
+ // return () {
|
|
|
|
+ // Log.d("CommunityPage dispose");
|
|
|
|
+ // };
|
|
|
|
+ // },[]);
|
|
|
|
+
|
|
|
|
+ return Scaffold(
|
|
|
|
+ appBar: MyAppBar.appBar(
|
|
|
|
+ context,
|
|
|
|
+ "Community",
|
|
|
|
+ backgroundColor: context.appColors.whiteBG,
|
|
|
|
+ ),
|
|
|
|
+ backgroundColor: context.appColors.backgroundDefault,
|
|
|
|
+ body: NestedScrollView(
|
|
|
|
+ headerSliverBuilder: (context, innerBoxIsScrolled) {
|
|
|
|
+ return [
|
|
|
|
+ SliverToBoxAdapter(
|
|
|
|
+ child: Consumer(
|
|
|
|
+ builder: (context, ref, _) {
|
|
|
|
+ final tabsRouter = ref.watch(communityVmProvider).tabsRouter;
|
|
|
|
+ // final vm = ref.read(communityVmProvider.notifier);
|
|
|
|
+ if(tabsRouter != null){
|
|
|
|
+ return _buildTopSection(context, ref, vm, tabsRouter);
|
|
|
|
+ }else {
|
|
|
|
+ return const SizedBox.shrink();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ // SliverPersistentHeader(
|
|
|
|
+ // pinned: true, // 吸顶
|
|
|
|
+ // delegate: CustomSliverPersistentHeaderDelegate(
|
|
|
|
+ // child: _buildTabsSection(contextPage, ref),
|
|
|
|
+ // ),
|
|
|
|
+ // ),
|
|
|
|
+ ];
|
|
|
|
+ },
|
|
|
|
+ body: AutoTabsRouter.pageView(
|
|
|
|
+ routes: const [
|
|
|
|
+ NewsPageRoute(),
|
|
|
|
+ FollowingPageRoute(),
|
|
|
|
+ ForyouPageRoute()
|
|
|
|
+ ],
|
|
|
|
+ builder: (context, child, pageController) {
|
|
|
|
+ final tabsRouter = AutoTabsRouter.of(context);
|
|
|
|
+ Log.d("autotabsRouter ---build ${tabsRouter.activeIndex}");
|
|
|
|
+ // 将tabsRouter 放入 CommunityVmProvider 中
|
|
|
|
+ // if(stateTabsRouter == null){
|
|
|
|
+ // vm.setTabsRouterAndPageController(tabsRouter, pageController);
|
|
|
|
+ // }else {
|
|
|
|
+ //
|
|
|
|
+ // }
|
|
|
|
+ vm.setTabsRouterAndPageController(tabsRouter, pageController);
|
|
|
|
+
|
|
|
|
+ return Column(
|
|
|
|
+ children: [
|
|
|
|
+ // Text("${vm.state.activeTabIdx}"),
|
|
|
|
+ // _buildTabsSection(contextPage, ref, tabsRouter),
|
|
|
|
+ // tabs 组件
|
|
|
|
+ // Visibility(
|
|
|
|
+ // visible: true,
|
|
|
|
+ // child: _buildTabsSection(contextPage, ref, tabsRouter),
|
|
|
|
+ // ),
|
|
|
|
+
|
|
|
|
+ // post 组件
|
|
|
|
+ // _buildPostSection(context, ref, vm),
|
|
|
|
+ Expanded(
|
|
|
|
+ child: child,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
Widget _buildTopSection(BuildContext context, WidgetRef ref, vm, tabsRouter) {
|
|
Widget _buildTopSection(BuildContext context, WidgetRef ref, vm, tabsRouter) {
|
|
final topSectionsData = vm.topSectionsData;
|
|
final topSectionsData = vm.topSectionsData;
|
|
final currentTabIdx = tabsRouter.activeIndex;
|
|
final currentTabIdx = tabsRouter.activeIndex;
|
|
- // 监听 curIdx 的变化
|
|
|
|
- // final curIdx = ref.watch(communityVmProvider.select((value) => value.curIdx));
|
|
|
|
return Container(
|
|
return Container(
|
|
color: Colors.white,
|
|
color: Colors.white,
|
|
padding: const EdgeInsets.only(top: 30, bottom: 30),
|
|
padding: const EdgeInsets.only(top: 30, bottom: 30),
|
|
@@ -55,35 +142,31 @@ class CommunityPage extends HookConsumerWidget {
|
|
decoration: BoxDecoration(
|
|
decoration: BoxDecoration(
|
|
// color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
|
|
// color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
|
|
shape: BoxShape.circle, // 设置为圆形
|
|
shape: BoxShape.circle, // 设置为圆形
|
|
- boxShadow: currentTabIdx == index ? [
|
|
|
|
|
|
+ boxShadow: index == 0 ? [
|
|
BoxShadow(
|
|
BoxShadow(
|
|
color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
|
|
color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
|
|
blurRadius: 5, // 设置模糊半径
|
|
blurRadius: 5, // 设置模糊半径
|
|
spreadRadius: 0.05, // 控制阴影扩散
|
|
spreadRadius: 0.05, // 控制阴影扩散
|
|
offset: const Offset(0, 4), // 设置阴影偏移量
|
|
offset: const Offset(0, 4), // 设置阴影偏移量
|
|
- ),
|
|
|
|
- ] : [],// 未选中时无阴影,
|
|
|
|
|
|
+ ), ] : [],// 未选中时无阴影,
|
|
),
|
|
),
|
|
child: MyAssetImage(
|
|
child: MyAssetImage(
|
|
item['icon'],
|
|
item['icon'],
|
|
width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
|
|
width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
|
|
height: 70,
|
|
height: 70,
|
|
).onTap(() {
|
|
).onTap(() {
|
|
- tabsRouter.setActiveIndex(index);
|
|
|
|
|
|
+ vm.handlerChangeCommunityType(context,index);
|
|
},
|
|
},
|
|
type: ClickType.throttle,
|
|
type: ClickType.throttle,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox.fromSize(size: const Size(0, 9)),
|
|
SizedBox.fromSize(size: const Size(0, 9)),
|
|
- Text(
|
|
|
|
|
|
+ MyTextView(
|
|
item['title'],
|
|
item['title'],
|
|
- maxLines: 1, // 设置最大行数为2
|
|
|
|
- overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontSize: 15.0,
|
|
|
|
- color: currentTabIdx == index ? ColorUtils.string2Color('#4161D0'):Colors.black,
|
|
|
|
- fontWeight: FontWeight.w500
|
|
|
|
- ), // 设置字体大小
|
|
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ textColor: index ==0 ? ColorUtils.string2Color('#4161D0'):Colors.black,
|
|
|
|
+ textAlign: TextAlign.center,
|
|
|
|
+ isFontMedium: true,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
@@ -94,66 +177,66 @@ class CommunityPage extends HookConsumerWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- @override
|
|
|
|
- Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
- final vm = ref.read(communityVmProvider.notifier);
|
|
|
|
-
|
|
|
|
- return Scaffold(
|
|
|
|
- appBar: MyAppBar.appBar(
|
|
|
|
- context,
|
|
|
|
- "Community",
|
|
|
|
- backgroundColor: context.appColors.whiteBG,
|
|
|
|
- ),
|
|
|
|
- backgroundColor: context.appColors.backgroundDefault,
|
|
|
|
- body: NestedScrollView(
|
|
|
|
- headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled){
|
|
|
|
- return <Widget>[
|
|
|
|
- SliverToBoxAdapter(
|
|
|
|
- child: Container(
|
|
|
|
- child: const SizedBox.shrink(),
|
|
|
|
- )
|
|
|
|
- ),
|
|
|
|
- SliverToBoxAdapter(
|
|
|
|
- child: Consumer(
|
|
|
|
- builder: (context, ref, _) {
|
|
|
|
- final tabsRouter = ref.watch(communityVmProvider).tabsRouter;
|
|
|
|
- final vm = ref.read(communityVmProvider.notifier);
|
|
|
|
- Log.d("community_page---buildTopSection ---${tabsRouter}");
|
|
|
|
- Log.d("community_page---buildTopSection ---${vm.state.curIdx}");
|
|
|
|
|
|
+ Widget _buildTabsSection(BuildContext context, WidgetRef ref, tabsRouter){
|
|
|
|
+ final vm = ref.read(communityVmProvider.notifier);
|
|
|
|
+ final tabsList = ref.watch(communityVmProvider.select((state) => state.tabsList));
|
|
|
|
+ return Container(
|
|
|
|
+ width: double.infinity,
|
|
|
|
+ padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
|
|
|
|
+ child: NewsfeedTabs(
|
|
|
|
+ key: UniqueKey(),
|
|
|
|
+ tabsList: tabsList!,
|
|
|
|
+ onClickAction:(activeTabIdx){
|
|
|
|
+ print('点击了tab ${activeTabIdx}');
|
|
|
|
+ // vm.handlerChangeTab(activeTabIdx);
|
|
|
|
+ // tabsRouter.setActiveIndex(activeTabIdx);
|
|
|
|
+ }
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
- // return _buildTopSection(context, ref, vm, tabsRouter);
|
|
|
|
- if(tabsRouter != null){
|
|
|
|
- return _buildTopSection(context, ref, vm, tabsRouter);
|
|
|
|
- }else {
|
|
|
|
- return const SizedBox.shrink();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ];
|
|
|
|
- },
|
|
|
|
- body: AutoTabsRouter.pageView(
|
|
|
|
- routes: const [
|
|
|
|
- NewsfeedPageRoute(),
|
|
|
|
- GaragesalePageRoute(),
|
|
|
|
- ],
|
|
|
|
- builder: (context, child, pageController) {
|
|
|
|
- final tabsRouter = AutoTabsRouter.of(context);
|
|
|
|
- // 设置当前的 useTag 0 newsFeed 1 garageSale
|
|
|
|
- vm.setCurrentUseTag(tabsRouter.activeIndex);
|
|
|
|
- // 将tabsRouter 放入 CommunityVmProvider 中
|
|
|
|
- vm.setTabsRouterAndPageController(tabsRouter, pageController);
|
|
|
|
- return Column(
|
|
|
|
- children: [
|
|
|
|
- // _buildTopSection(context, ref, vm, tabsRouter),
|
|
|
|
- Expanded(
|
|
|
|
- child: child,
|
|
|
|
|
|
+ Widget _buildPostSection(BuildContext context, WidgetRef ref, vm){
|
|
|
|
+ return Container(
|
|
|
|
+ height: 65.5,
|
|
|
|
+ width: double.infinity,
|
|
|
|
+ padding: const EdgeInsets.only(left: 20, right: 20),
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ child: Row(
|
|
|
|
+ children: [
|
|
|
|
+ const MyAssetImage(Assets.communityNesFeed, width: 45,height: 45,),
|
|
|
|
+ Expanded(
|
|
|
|
+ child: Row(
|
|
|
|
+ children: [
|
|
|
|
+ Expanded(
|
|
|
|
+ child: Container(
|
|
|
|
+ // height: 65.5,
|
|
|
|
+ // color: Colors.blue,
|
|
|
|
+ child: MyTextView(
|
|
|
|
+ "What’s on your mind?",
|
|
|
|
+ textColor: ColorUtils.string2Color('#000000'),
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ marginLeft: 15,
|
|
|
|
+ alignment: Alignment.centerLeft,
|
|
|
|
+ textAlign: TextAlign.left,
|
|
|
|
+ backgroundColor: ColorUtils.string2Color('#ffffff'),
|
|
|
|
+ maxLines: 1,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
- ],
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
|
|
+ ),
|
|
|
|
+ const MyAssetImage(
|
|
|
|
+ Assets.communityCamera,
|
|
|
|
+ width: 21,
|
|
|
|
+ height: 16.5,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ).onTap((){
|
|
|
|
+ vm.handlerGotoPost(context);
|
|
|
|
+ }),
|
|
),
|
|
),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
);
|
|
);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|