Skip to content

Commit

Permalink
新增 bottomAppBar 第二种样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadaski committed Jul 25, 2019
1 parent 5aa0510 commit 81d025c
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
Binary file added image/bottom_app_bar2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions mecury_project/example/bottom_appbar_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## 简介
使用bottomAppbar进行底部导航,并居中浮动按钮的demo
## 样例
## 样例1
![](../../../image/bottom_app_bar.png)

## 样例2

![bottom_app_bar2](../../../image/bottom_app_bar2.png)

## Getting Started

For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
[documentation](https://flutter.io/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'each_view.dart';

class BottomAppBarDemo extends StatefulWidget {
@override
_BottomAppBarDemoState createState() => _BottomAppBarDemoState();
}

class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
List<Widget> _eachView;
int _index = 0;

@override
void initState() {
// TODO: implement initState
super.initState();
_eachView = List();
_eachView..add(EachView('home'))..add(EachView('me'));
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: _eachView[_index],
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.lightBlueAccent,
elevation: 0,
onPressed: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) {
return EachView('New Page');
}));
},
tooltip: 'Increment',
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: SizedBox(
height: 48,
width: 48,
child: Icon(Icons.add,color: Colors.lightBlueAccent,)),
),
), // T
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked, // his
bottomNavigationBar: BottomAppBar(
elevation: 8,
color: Colors.lightBlueAccent,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: Icon(Icons.near_me),
color: Colors.white,
onPressed: () {
setState(() {
_index = 0;
});
},
),
IconButton(
icon: Icon(Icons.edit_location),
color: Colors.white,
onPressed: () {
setState(() {
_index = 1;
});
},
),
],
),
),
);
}
}
5 changes: 4 additions & 1 deletion mecury_project/example/bottom_appbar_demo/lib/each_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ class _EachViewState extends State<EachView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget._title),),
appBar: AppBar(
title: Text(widget._title),
backgroundColor: Colors.lightBlueAccent,
),
);
}
}
3 changes: 2 additions & 1 deletion mecury_project/example/bottom_appbar_demo/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'bottom_appBar_demo.dart';
//import 'bottom_appBar_demo.dart';
import 'bottom_appBar_demo2.dart';

void main() => runApp(new MyApp());

Expand Down

0 comments on commit 81d025c

Please sign in to comment.