码迷,mamicode.com
首页 > 其他好文 > 详细

头部搜索导航布局, 修改主题样式

时间:2020-02-29 20:32:17      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:containe   homepage   ons   idg   主题   creat   nav   tom   修改   

import ‘package:flutter/material.dart‘;
import ‘package:flutter_jdshop/services/ScreenAdapter.dart‘;

import ‘Home.dart‘;
import ‘Category.dart‘;
import ‘Cart.dart‘;
import ‘User.dart‘;


class Tabs extends StatefulWidget {
Tabs({Key key}) : super(key: key);

_TabsState createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
int _currentIndex = 0;
PageController _pageController;
@override
void initState() {
super.initState();
this._pageController = new PageController(initialPage: this._currentIndex);
}

List<Widget> _pageList = [HomePage(), CategoryPage(), CartPage(), UserPage()];

@override
Widget build(BuildContext context) {

ScreenAdapter.init(context);

return Scaffold(
appBar: _currentIndex!=3?AppBar(
leading: IconButton(
icon: Icon(Icons.center_focus_weak, size: 28, color: Colors.black87),
onPressed: null,
),
title: InkWell(
child: Container(
height: ScreenAdapter.height(68),
decoration: BoxDecoration(
color: Color.fromRGBO(233, 233, 233, 0.8),
borderRadius: BorderRadius.circular(30)
),
padding: EdgeInsets.only(left: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(Icons.search),
Text("笔记本",style: TextStyle(
fontSize: ScreenAdapter.size(28)
))
],
),
),
onTap: (){
Navigator.pushNamed(context, ‘/search‘);

},
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.message, size: 28, color: Colors.black87),
onPressed: null,
)
],
):AppBar(
title: Text("用户中心"),
),
body: PageView(
controller: this._pageController,
children: this._pageList,
onPageChanged: (index) {
setState(() {
this._currentIndex = index;
});
},
physics: NeverScrollableScrollPhysics(), //禁止pageView滑动
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: this._currentIndex,
onTap: (index) {
setState(() {
this._currentIndex = index;
this._pageController.jumpToPage(index);
});
},
type: BottomNavigationBarType.fixed,
fixedColor: Colors.red,
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("首页")),
BottomNavigationBarItem(
icon: Icon(Icons.category), title: Text("分类")),
BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart), title: Text("购物车")),
BottomNavigationBarItem(icon: Icon(Icons.people), title: Text("我的"))
],
),
);
}
}

头部搜索导航布局, 修改主题样式

标签:containe   homepage   ons   idg   主题   creat   nav   tom   修改   

原文地址:https://www.cnblogs.com/zhaofeis/p/12384936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!