|
@@ -1,4 +1,6 @@
|
|
|
+import 'package:douyin_demo/main.dart';
|
|
|
import 'package:douyin_demo/pages/sameCity/SameCityPage.dart';
|
|
|
+import 'package:douyin_demo/providers/RecommendProvider.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
// class BtmBar extends StatelessWidget {
|
|
@@ -40,6 +42,12 @@ class _BtmBarState extends State<BtmBar> {
|
|
|
}
|
|
|
selected[widget.selectIndex] = true;
|
|
|
}
|
|
|
+
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ // _controller.dispose();
|
|
|
+ super.dispose();
|
|
|
+}
|
|
|
|
|
|
tapItem(index) {
|
|
|
// selected=List<bool>();
|
|
@@ -48,57 +56,81 @@ class _BtmBarState extends State<BtmBar> {
|
|
|
// }
|
|
|
// selected[index]=true;
|
|
|
// setState(() {
|
|
|
-
|
|
|
+
|
|
|
// selected=selected;
|
|
|
// });
|
|
|
- Navigator.push(context, MaterialPageRoute(builder: (context)=>SameCityMain(selIndex: index,)));
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ Navigator.pushAndRemoveUntil(
|
|
|
+ context,
|
|
|
+ MaterialPageRoute(
|
|
|
+ builder: (context) => RecommendPage(
|
|
|
+ selIndex: index,
|
|
|
+ )),
|
|
|
+ ModalRoute.withName("/Home"));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ Navigator.pushAndRemoveUntil(
|
|
|
+ context,
|
|
|
+ MaterialPageRoute(
|
|
|
+ builder: (context) => SameCityMain(
|
|
|
+ selIndex: index,
|
|
|
+ )),
|
|
|
+ ModalRoute.withName("/sameCity"));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
// RecommendProvider provider = Provider.of<RecommendProvider>(context);
|
|
|
- double rpx=MediaQuery.of(context).size.width/750;
|
|
|
+ double rpx = MediaQuery.of(context).size.width / 750;
|
|
|
return Container(
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
children: <Widget>[
|
|
|
Expanded(
|
|
|
- flex: 1,
|
|
|
- child: getBtmTextWidget("首页", selected[0],(){tapItem(0);},rpx)
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- flex: 1,
|
|
|
- child: getBtmTextWidget("同城", selected[1],(){tapItem(1);},rpx)
|
|
|
- ),
|
|
|
+ flex: 1,
|
|
|
+ child: getBtmTextWidget("首页", selected[0], () {
|
|
|
+ tapItem(0);
|
|
|
+ }, rpx)),
|
|
|
Expanded(
|
|
|
- flex: 1,
|
|
|
- child: AddIcon()
|
|
|
- ),
|
|
|
+ flex: 1,
|
|
|
+ child: getBtmTextWidget("同城", selected[1], () {
|
|
|
+ tapItem(1);
|
|
|
+ }, rpx)),
|
|
|
+ Expanded(flex: 1, child: AddIcon()),
|
|
|
Expanded(
|
|
|
- flex: 1,
|
|
|
- child: getBtmTextWidget("消息", selected[2],(){tapItem(2);},rpx)
|
|
|
- ),
|
|
|
+ flex: 1,
|
|
|
+ child: getBtmTextWidget("消息", selected[2], () {
|
|
|
+ tapItem(2);
|
|
|
+ }, rpx)),
|
|
|
Expanded(
|
|
|
- flex: 1,
|
|
|
- child: getBtmTextWidget("我", selected[3],(){tapItem(3);},rpx)
|
|
|
- ),
|
|
|
+ flex: 1,
|
|
|
+ child: getBtmTextWidget("我", selected[3], () {
|
|
|
+ tapItem(3);
|
|
|
+ }, rpx)),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-getBtmTextWidget(String content, bool ifSelected,tapFunc,double rpx) {
|
|
|
+getBtmTextWidget(String content, bool ifSelected, tapFunc, double rpx) {
|
|
|
return FlatButton(
|
|
|
- onPressed: () {tapFunc();},
|
|
|
+ onPressed: () {
|
|
|
+ tapFunc();
|
|
|
+ },
|
|
|
child: Text("$content",
|
|
|
style: ifSelected
|
|
|
? TextStyle(
|
|
|
- fontSize: 30*rpx,
|
|
|
+ fontSize: 30 * rpx,
|
|
|
color: Colors.white,
|
|
|
fontWeight: FontWeight.w900)
|
|
|
: TextStyle(
|
|
|
- fontSize: 30*rpx,
|
|
|
+ fontSize: 30 * rpx,
|
|
|
color: Colors.grey[600],
|
|
|
fontWeight: FontWeight.w900)));
|
|
|
}
|
|
@@ -108,15 +140,15 @@ class AddIcon extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- double rpx=MediaQuery.of(context).size.width/750;
|
|
|
- double iconHeight = 55*rpx;
|
|
|
- double totalWidth = 90*rpx;
|
|
|
- double eachSide = 5*rpx;
|
|
|
+ double rpx = MediaQuery.of(context).size.width / 750;
|
|
|
+ double iconHeight = 55 * rpx;
|
|
|
+ double totalWidth = 90 * rpx;
|
|
|
+ double eachSide = 5 * rpx;
|
|
|
return Container(
|
|
|
// decoration: BoxDecoration(),
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 30*rpx),
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 30 * rpx),
|
|
|
height: iconHeight,
|
|
|
- width: 150*rpx,
|
|
|
+ width: 150 * rpx,
|
|
|
child: Stack(
|
|
|
children: <Widget>[
|
|
|
Positioned(
|