import 'package:flutter/material.dart';
/// 我的页面
/// @author: dingwen
/// @date: 2021/5/9
class MyPage extends StatefulWidget {
@override
_MyPageState createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
// 标题
title: Text('我的'),
// 标题是否居中
centerTitle: true,
// 背景颜色
backgroundColor: Colors.blue,
// 阴影
elevation: 20.0,
// 左边 widget
leading: BackButton(),
// 后边选项
actions: <Widget>[
IconButton(icon: Icon(Icons.search), onPressed: () => print("搜索")),
PopupMenuButton<String>(
itemBuilder: (context) => _getPopupMenu(context),
onSelected: (String value) => print(value),
)
],
// appBar 底部选择Tab
bottom: TabBar(
tabs: <Widget>[
Tab(icon: Icon(Icons.add),text: '添加',),
Tab(icon: Icon(Icons.home),text: "首页",),
],
),
),
body: TabBarView(
children: [
Text('add'),
Text('home page'),
],
),
),
);
}
/// 构建弹出菜单项
_getPopupMenu(BuildContext context) {
return <PopupMenuEntry<String>>[
PopupMenuItem(
value: 'qq',
child: Text('qq'),
),
PopupMenuItem(
value: "wechat",
child: Text('wechat'),
)
];
}
}