Browse Source

no message

ios
ZHR007 4 months ago
parent
commit
d476ebb4b7
6 changed files with 51 additions and 316 deletions
  1. 1
      lib/pages/discover/discover_page.dart
  2. 39
      lib/pages/home/recommend_tab.dart
  3. 55
      lib/pages/main/main_page.dart
  4. 182
      lib/pages/main/tabbar/main_tab_bar.dart
  5. 77
      lib/pages/main/tabbar/main_tab_btn.dart
  6. 13
      lib/pages/main/tabbar/main_tab_item.dart

1
lib/pages/discover/discover_page.dart

@ -62,7 +62,6 @@ class _DiscoverPageState extends State<DiscoverPage>
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12.w),
height: MediaQuery.of(context).size.height - 64,
// constraints: BoxConstraints(minHeight: ScreenUtil().setHeight(800)),
child: Column(
children: [

39
lib/pages/home/recommend_tab.dart

@ -90,38 +90,32 @@ class _RecommendTabState extends State<RecommendTab>
_refreshController.finishLoad(IndicatorResult.fail);
}
},
child: SizedBox(
height: MediaQuery.of(context).size.height - totalBottomPadding,
child: ListView.separated(
child: ListView.separated(
// 使
// padding AppBar
padding: EdgeInsets.only(left: 12, right: 12, bottom: 12),
padding: EdgeInsets.only(left: 12, right: 12, top: 12),
itemBuilder: (context, index) {
//
if (controller.recommendFeed.isEmpty && index == 0) {
// 使
if (controller.recommendIsLoading.value) {
return SizedBox(
height: MediaQuery.of(context).size.height - totalBottomPadding,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('加载数据中...'),
],
),
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('加载数据中...'),
],
),
);
} else {
return SizedBox(
height: MediaQuery.of(context).size.height - totalBottomPadding,
child: const Center(
child: Text(
"暂无数据",
style: TextStyle(fontSize: 14, color: Color(0xFF999999)),
),
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('暂无数据'),
],
),
);
}
@ -140,7 +134,6 @@ class _RecommendTabState extends State<RecommendTab>
// item
itemCount: controller.recommendFeed.isEmpty ? 1 : controller.recommendFeed.length,
)
),
);
});
}

55
lib/pages/main/main_page.dart

@ -1,5 +1,4 @@
import 'package:dating_touchme_app/generated/assets.dart';
import 'package:dating_touchme_app/pages/main/tabbar/main_tab_bar.dart';
import 'package:dating_touchme_app/pages/message/message_page.dart';
import 'package:dating_touchme_app/pages/mine/mine_page.dart';
import 'package:dating_touchme_app/rtc/rtm_manager.dart';
@ -10,6 +9,7 @@ import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:dating_touchme_app/controller/mine/user_controller.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../../extension/router_service.dart';
import '../../widget/double_tap_to_exit_widget.dart';
@ -87,29 +87,44 @@ class _MainPageState extends State<MainPage> {
child: Scaffold(
backgroundColor: Colors.transparent,
resizeToAvoidBottomInset: false,
body: Stack(
alignment: Alignment.bottomCenter,
body: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
children: [
PageView(
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
children: [
homePage, // 使
discoverPage,
messagePage,
minePage,
],
),
MainTabBar(
initialIndex: currentIndex,
onTabChanged: (index) {
currentIndex = index;
pageController.jumpToPage(index);
},
),
homePage, // 使
discoverPage,
messagePage,
minePage,
],
),
bottomNavigationBar: TDBottomTabBar(
currentIndex: currentIndex,
TDBottomTabBarBasicType.iconText,
componentType: TDBottomTabBarComponentType.normal,
useVerticalDivider: false,
navigationTabs: [
tabItem('首页', Assets.imagesHomePre, Assets.imagesHomeNol, 0),
tabItem('找对象', Assets.imagesDiscoverPre, Assets.imagesDiscoverNol, 1),
tabItem('消息', Assets.imagesMessagePre, Assets.imagesMessageNol, 2),
tabItem('我的', Assets.imagesMinePre, Assets.imagesMineNol, 3),
]
)
),
);
}
/// item
TDBottomTabBarTabConfig tabItem(String title, String selectedIcon, String unselectedIcon, int index) {
return TDBottomTabBarTabConfig(
tabText: title,
selectedIcon: Image.asset(selectedIcon, width: 25, height: 25, fit: BoxFit.cover),
unselectedIcon: Image.asset(unselectedIcon, width: 25, height: 25, fit: BoxFit.cover),
selectTabTextStyle: TextStyle(color: Color(0xFFED4AC3)),
unselectTabTextStyle: TextStyle(color: Color(0xFF999999)),
onTap: () {
currentIndex = index;
pageController.jumpToPage(index);
},
);
}
}

182
lib/pages/main/tabbar/main_tab_bar.dart

@ -1,182 +0,0 @@
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dating_touchme_app/extension/ex_context.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../generated/assets.dart';
import 'main_tab_btn.dart';
import 'main_tab_item.dart';
class MainTabBar extends StatefulWidget {
const MainTabBar({super.key, this.initialIndex = 0, this.onTabChanged});
final int initialIndex;
final void Function(int index)? onTabChanged;
@override
State<MainTabBar> createState() => _MainTabBarState();
}
class _MainTabBarState extends State<MainTabBar> {
int _selecteIndex = 0;
final List<MainTabItem> items = const [
MainTabItem(
title: "首页",
icon: Assets.imagesHomeNol,
selectedIcon: Assets.imagesHomePre,
),
MainTabItem(
title: "找对象",
icon: Assets.imagesDiscoverNol,
selectedIcon: Assets.imagesDiscoverPre,
),
MainTabItem(
title: "消息",
icon: Assets.imagesMessageNol,
selectedIcon: Assets.imagesMessagePre,
),
MainTabItem(
title: "我的",
icon: Assets.imagesMineNol,
selectedIcon: Assets.imagesMinePre,
),
];
@override
void initState() {
_selecteIndex = widget.initialIndex;
super.initState();
}
@override
void didUpdateWidget(covariant MainTabBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (_selecteIndex != widget.initialIndex) {
_selecteIndex = widget.initialIndex;
}
}
@override
Widget build(BuildContext context) {
return Builder(builder: (context) {
if (Platform.isIOS) {
if (context.bottomPadding > 0) {
return Container(
height: 64.w,
color: Colors.white,
child: Stack(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: items.mapIndexed((index, item) {
return MainTabButton(
selected: index == _selecteIndex,
isRedDot: item.showRedDot,
title: item.title,
onTap: () {
if (_selecteIndex != index) {
_selecteIndex = index;
setState(() {});
widget.onTabChanged?.call(index);
}
},
icon: item.icon,
selectedIcon: item.selectedIcon,
);
}).toList()),
SizedBox(
height: 22.w,
)
],
)
],
),
);
} else {
return SafeArea(
top: false,
child: Container(
height: 64.w,
color: Colors.white,
child: Stack(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: items.mapIndexed((index, item) {
return MainTabButton(
selected: index == _selecteIndex,
isRedDot: item.showRedDot,
title: item.title,
onTap: () {
if (_selecteIndex != index) {
_selecteIndex = index;
setState(() {});
widget.onTabChanged?.call(index);
}
},
icon: item.icon,
selectedIcon: item.selectedIcon,
);
}).toList()),
SizedBox(
height: 14.w,
)
],
)
],
),
),
);
}
} else {
return SafeArea(
top: false,
child: Container(
// padding: EdgeInsets.only(bottom: 14.w),
// margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 14.w),
height: 64.w,
color: Colors.white,
child: Stack(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: items.mapIndexed((index, item) {
return MainTabButton(
selected: index == _selecteIndex,
isRedDot: item.showRedDot,
title: item.title,
onTap: () {
if (_selecteIndex != index) {
_selecteIndex = index;
setState(() {});
widget.onTabChanged?.call(index);
}
},
icon: item.icon,
selectedIcon: item.selectedIcon,
);
}).toList()),
SizedBox(
height: 14.w,
)
],
)
],
),
),
);
}
});
}
}

77
lib/pages/main/tabbar/main_tab_btn.dart

@ -1,77 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MainTabButton extends StatefulWidget {
final VoidCallback? onTap;
final bool isRedDot;
final bool selected;
final String icon;
final String title;
final String selectedIcon;
const MainTabButton({
super.key,
required this.selected,
required this.icon,
required this.selectedIcon,
this.isRedDot = false,
this.onTap,
required this.title
});
@override
State<MainTabButton> createState() => MainTabButtonState();
}
class MainTabButtonState extends State<MainTabButton> {
@override
Widget build(BuildContext context) {
if (widget.isRedDot) {
return Expanded(
child: GestureDetector(
onTap: widget.onTap,
child: Container(
color: Colors.transparent,
alignment: Alignment.center,
child: Stack(
clipBehavior: Clip.none,
children: [
Column(
children: [
SizedBox(height: 5.w,),
widget.selected
? Image.asset(widget.selectedIcon, width: 25.w, height: 25.w)
: Image.asset(widget.icon, width: 25.w, height: 25.w),
Text(widget.title, style: const TextStyle(
fontSize: 12
),)
],
),
],
),
),
));
}
return Expanded(
child: GestureDetector(
onTap: widget.onTap,
child: Container(
alignment: Alignment.center,
color: Colors.transparent,
child: Column(
children: [
SizedBox(height: 5.w,),
widget.selected
? Image.asset(widget.selectedIcon, width: 25.w, height: 25.w)
: Image.asset(widget.icon, width: 25.w, height: 25.w),
Text(widget.title, style: const TextStyle(
fontSize: 12
),)
],
),
),
),
);
}
}

13
lib/pages/main/tabbar/main_tab_item.dart

@ -1,13 +0,0 @@
class MainTabItem {
final String title;
final String icon;
final String selectedIcon;
final bool showRedDot;
const MainTabItem({
required this.title,
required this.icon,
required this.selectedIcon,
this.showRedDot = false,
});
}
Loading…
Cancel
Save