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

commit

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