Commit 0a4e2416 authored by 林生雨's avatar 林生雨

commit

parent 049544f6
......@@ -24,6 +24,8 @@ class AlbumModel extends BaseModel {
LiveData<List<DirBean>> dirLive = LiveData();
LiveData<String> titleData = LiveData();
LiveData<int> backLive = LiveData();
Map<String, List<ScanImageItem>> _mainValue = Map();
List<String> _selectList = List();
String _nowDirName = MainDir;
......@@ -93,7 +95,6 @@ class AlbumModel extends BaseModel {
if (value != null) {
_mainValue = value;
value.forEach((key, eachValue) {
print("VALUE!!! $key");
if (eachValue != null && !eachValue.isEmpty) {
if (key == MainDir) {
titleData.notifyView(MainDirExplain);
......@@ -120,6 +121,8 @@ class AlbumModel extends BaseModel {
if (_listen != null) {
_listen.cancel();
}
selectSizeLive.dispost();
backLive.dispost();
albumLive.dispost();
dirLive.dispost();
titleData.dispost();
......@@ -212,7 +215,7 @@ class AlbumModel extends BaseModel {
void changPopState() {
if (showPop) {
showPop = false;
dirLive.notifyView(null);
dirLive.notifyView(_dirList);
} else {
showPop = true;
dirLive.notifyView(_dirList);
......@@ -227,8 +230,22 @@ class AlbumModel extends BaseModel {
dirName = MainDir;
}
_nowDirName = dirName;
dirLive.notifyView(null);
changPopState();
showPop = false;
albumLive.notifyView(_mainValue[dirName]);
}
void backAnim(double dy) {
if (dy < 0.2) {
backLive.notifyView(null);
return;
}
String alp = "${(dy.abs() * (99)).toInt()}";
if (alp.length == 1) {
alp = "0$alp";
}
String colorString = "0x${alp}000000";
print(colorString);
backLive.notifyView(int.parse(colorString));
}
}
......@@ -26,10 +26,11 @@ class AlbumPage extends StatefulWidget {
class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
final AlbumModel _model;
String colorString = "0x00000000";
AlbumState(this._model);
Animation<double> animation;
Animation<Offset> animation;
AnimationController controller;
@override
......@@ -37,17 +38,22 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
super.initState();
_model.initScanImages(context);
controller = new AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
animation = new Tween(begin: 0.0, end: 1.0).animate(controller)
..addListener(() {
print("LISTEN!! ${animation.value}");
});
duration: const Duration(milliseconds: 300), vsync: this);
animation =
new Tween(begin: Offset(0, -1), end: Offset(0, 0)).animate(controller)
..addListener(() {
_model.backAnim(1 - animation.value.dy.abs());
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: baseAppBarChangeTitle(
backClick: (){
Navigator.pop(context,null);
},
centerTitle: true,
title: GestureDetector(
onTap: () {
_model.changPopState();
......@@ -75,6 +81,7 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
),
text,
Container(
alignment: Alignment.center,
margin: EdgeInsets.fromLTRB(1, 0, 0, 0),
child: Transform(
transform: Matrix4.identity()
......@@ -98,8 +105,8 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
initialData: _model.selectSizeLive.data,
builder: (c, data) {
String showText = "下一步";
if (data != 0) {
showText = "$showText($data)";
if (data.data != null && data.data != 0) {
showText = "$showText(${data.data})";
}
return Center(
child: GestureDetector(
......@@ -118,6 +125,24 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
body: Stack(
children: <Widget>[
mainView(),
StreamBuilder<int>(
stream: _model.backLive.stream,
initialData: _model.backLive.data,
builder: (con, data) {
if (data.data == null) {
return Container();
}
return GestureDetector(
onTap: () {
_model.changPopState();
},
child: Container(
width: double.maxFinite,
height: double.maxFinite,
color: Color(data.data),
));
},
),
popWindow(),
],
));
......@@ -136,7 +161,6 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
initialData: _model.albumLive.data,
builder:
(BuildContext context, AsyncSnapshot<List<ScanImageItem>> imgList) {
print("FINALL $imgList ${imgList.data}");
if (imgList.data == null) {
return Center(child: CircularProgressIndicator());
}
......@@ -230,57 +254,53 @@ class AlbumState extends State<AlbumPage> with SingleTickerProviderStateMixin {
builder: (BuildContext context, AsyncSnapshot<List<DirBean>> snapshot) {
if (snapshot.data == null) {
return Container();
} else {
}
if (_model.showPop) {
controller.forward();
return Stack(
children: <Widget>[
Container(
width: double.maxFinite,
height: double.maxFinite,
color: Colors.black54,
),
popWindowList(snapshot)
],
);
} else {
controller.reverse();
}
return popWindowList(snapshot);
});
}
popWindowList(AsyncSnapshot<List<DirBean>> snapshot) {
return Container(
padding: EdgeInsets.fromLTRB(16, 3, 16, 3),
color: Colors.white,
height: 280 * animation.value,
child: ListView.separated(
separatorBuilder: (context, index) {
return Divider();
},
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () => _model.selectDir(index),
child: Row(
children: <Widget>[
Container(
width: 50,
height: 50,
child: Image.file(
snapshot.data[index].pic,
fit: BoxFit.cover,
),
),
Container(
padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
child: Text(
"${snapshot.data[index].dirName} (${snapshot.data[index].picCount})"),
),
Expanded(
child: Container(),
return SlideTransition(
position: animation,
child: Container(
padding: EdgeInsets.fromLTRB(16, 3, 16, 3),
color: Colors.white,
height: 280,
child: ListView.separated(
separatorBuilder: (context, index) {
return Divider();
},
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () => _model.selectDir(index),
child: Row(
children: <Widget>[
Container(
width: 50,
height: 50,
child: Image.file(
snapshot.data[index].pic,
fit: BoxFit.cover,
),
),
Container(
padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
child: Text(
"${snapshot.data[index].dirName} (${snapshot.data[index].picCount})"),
),
Expanded(
child: Text(""),
),
Icon(Icons.chevron_right)
],
),
Icon(Icons.chevron_right)
],
),
);
}));
);
})));
}
}
......@@ -82,7 +82,7 @@ class TestPage extends StatelessWidget {
Navigator.push(
context,
new CustomRoute(RouterCenterImpl().findAlbumRouter()?.getAlbumPage(
"com.example.gengmei_flutter_plugin_example", true, 1, null)));
"com.example.gengmei_flutter_plugin_example", true, 9, null)));
}, "相册页面");
}
......
......@@ -119,12 +119,12 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
title: 'Flutter Boost example',
debugShowCheckedModeBanner: false,
routes: {
'/': (context) {
return TestPage();
},
},
builder: FlutterBoost.init(),
// routes: {
// '/': (context) {
// return TestPage();
// },
// },
builder: buildOnce,
theme: new ThemeData(
primaryColor: Colors.white,
backgroundColor: Color(0xFFEFEFEF),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment