127 lines
4.1 KiB
Dart
127 lines
4.1 KiB
Dart
|
|
import 'package:circle_app/util/util.dart';
|
|
import 'package:circle_app/view/ExitAppConfirmation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'logic.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
|
|
@override
|
|
bool get wantKeepAlive => true;
|
|
final logic = Get.lazyPut(() => HomeLogic());
|
|
|
|
final state = Get.find<HomeLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
super.build(context);
|
|
|
|
return GetBuilder(builder: (HomeLogic controller) {
|
|
return ExitAppConfirmation(child: Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
// backgroundColor: Color.fromRGBO(244, 245, 245, 1.0),
|
|
bottomNavigationBar: Container(
|
|
height: 49.sp + MediaQuery.of(context).padding.bottom,
|
|
width: Get.width,
|
|
// color: Colors.red,
|
|
padding: EdgeInsets.only(left: 50.sp, right: 50.sp),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF423055),
|
|
image: DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: AssetImage(
|
|
getTabbarImage('tabbar_bg'),
|
|
))),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
funcItem(0, 'msg', 0 == controller.currentIndex, controller),
|
|
funcItem(1, 'circle', 1 == controller.currentIndex, controller),
|
|
funcItem(2, 'mine', 2 == controller.currentIndex, controller),
|
|
],
|
|
),
|
|
),
|
|
body: PageView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
controller: controller.pageController,
|
|
onPageChanged: (int index) {
|
|
// controller.updateIndex(index);
|
|
},
|
|
children: controller.tabs,
|
|
),
|
|
),);
|
|
});
|
|
}
|
|
|
|
funcItem(int index, String image, bool isSelected, HomeLogic controller) {
|
|
return SizedBox(
|
|
width: 80.sp,
|
|
height: 36.sp,
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
if (!isSelected) {
|
|
controller.pageController.jumpToPage(index);
|
|
controller.updateIndex(index);
|
|
}
|
|
},
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children:[
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(top: 8.sp),
|
|
child: Center(
|
|
child: Image.asset(
|
|
isSelected
|
|
? getTabbarImage('${image}_selected')
|
|
: getTabbarImage('${image}_normal'),
|
|
width: 34.sp,
|
|
height: 34.sp,
|
|
),
|
|
),
|
|
),
|
|
// Obx(() => null)
|
|
Obx(() => Visibility(
|
|
visible: index == 0 &&controller.unreadSIze!="0",
|
|
child: Positioned(
|
|
// right: 4.sp,
|
|
top: 4.sp,
|
|
child:
|
|
Container(
|
|
margin: EdgeInsets.only(left: int.parse(controller.unreadSIze.value) > 99 ? 30.sp : 20.sp),
|
|
height: 18.sp,
|
|
padding: EdgeInsets.only(left: 5.sp,right: 5.sp),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Colors.red,
|
|
borderRadius: BorderRadius.circular(11.sp)
|
|
),
|
|
child: Text(
|
|
int.parse(controller.unreadSIze.value) > 99 ? '99+' : controller.unreadSIze.value, // The number in the red dot
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12.0.sp, // Font size of the text
|
|
),
|
|
),
|
|
),
|
|
|
|
)))
|
|
|
|
]
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|