first commit
This commit is contained in:
1
untitled/lib/widget/.pydio
Normal file
1
untitled/lib/widget/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
74a003d3-5e86-40b6-b3f1-d5d4c1b224a6
|
||||
36
untitled/lib/widget/CachedNetworkImage.dart
Normal file
36
untitled/lib/widget/CachedNetworkImage.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
|
||||
/// 缓存网络图片
|
||||
/// 第一次加载网络图,第二次从内存直接获取
|
||||
/// TODO 可以缓存图片到硬盘
|
||||
class CachedNetworkImg extends StatelessWidget {
|
||||
|
||||
String url;
|
||||
|
||||
CachedNetworkImg(this.url);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: url,
|
||||
placeholder: (context, url) => Container(
|
||||
width: 130,
|
||||
height: 80,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: ColorConfig.ThemeColor,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
fit: BoxFit.cover,
|
||||
width: Screen.setWidth(375),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
58
untitled/lib/widget/CellWidget.dart
Normal file
58
untitled/lib/widget/CellWidget.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
|
||||
/// cell 组件
|
||||
class CellWidget extends StatelessWidget {
|
||||
final Widget leftIcon;
|
||||
final Widget leftText;
|
||||
|
||||
final Widget rightIcon;
|
||||
final Widget rightText;
|
||||
final Function onTap;
|
||||
final double padding;
|
||||
|
||||
CellWidget({
|
||||
this.leftIcon,
|
||||
this.leftText,
|
||||
this.rightIcon = const Icon(Icons.arrow_right_rounded,color: ColorConfig.NoActiveColor,size: 30,),
|
||||
this.rightText = const Text(""),
|
||||
this.onTap,
|
||||
this.padding = 15
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
onTap();
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: Screen.setFontSize(padding),right: Screen.setFontSize(padding)),
|
||||
height: Screen.setHeight(40),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
leftIcon,
|
||||
SizedBox(width: Screen.setWidth(10),),
|
||||
leftText
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
rightText,
|
||||
SizedBox(width: Screen.setWidth(10),),
|
||||
rightIcon
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
59
untitled/lib/widget/FutureBuilderWidget.dart
Normal file
59
untitled/lib/widget/FutureBuilderWidget.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
|
||||
/// 异步数据请求,封装成组件,数据类型通过泛型传入
|
||||
class FutureBuilderWidget<O> extends StatelessWidget {
|
||||
final Function future; // future 异步方法
|
||||
final Widget Function(O res) success; // 请求成功后展示的widget方法
|
||||
FutureBuilderWidget({
|
||||
@required this.future,
|
||||
@required this.success
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: future(),
|
||||
builder: (BuildContext context, AsyncSnapshot<O> snapshot) {
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return Center(
|
||||
child: SpinKitWave(color: ColorConfig.ThemeColor, itemCount: 3, size: 40),
|
||||
);
|
||||
break;
|
||||
case ConnectionState.done:
|
||||
if (snapshot.hasError) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: Screen.setHeight(100)),
|
||||
alignment: AlignmentDirectional.center,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.error,size: 50,color: ColorConfig.ThemeColor,),
|
||||
SizedBox(height: 10,),
|
||||
Text("网络出现问题", style: TextStyle(fontSize: 16,color: ColorConfig.TitleColor),),
|
||||
SizedBox(height: 8,),
|
||||
Text(snapshot.error.toString(),style: TextStyle(fontSize: 14,color: ColorConfig.TextColor),),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
FutureBuilderWidget(future: future, success: success,);
|
||||
},
|
||||
child: Icon(Icons.refresh,size: 30,color: ColorConfig.ThemeColor,),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return success(snapshot.data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
160
untitled/lib/widget/ItemWidget.dart
Normal file
160
untitled/lib/widget/ItemWidget.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:peach/entity/_.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
|
||||
class ItemWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ItemWidget();
|
||||
|
||||
List<ItemList> data = []; // list 列表数据
|
||||
String title; // 标题
|
||||
Function longPress; // 列表item被点击后的事件回调
|
||||
|
||||
ItemWidget({
|
||||
this.data,
|
||||
// this.isShowTitle = true,
|
||||
this.title = "",
|
||||
this.longPress,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class _ItemWidget extends State<ItemWidget> {
|
||||
|
||||
|
||||
Widget TipsItem({ String title}) {
|
||||
return title == 'null' ? Text('') : Container(
|
||||
padding: EdgeInsets.only(top: 2,bottom: 2,left: 5,right: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConfig.ThemeColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
),
|
||||
child: Text(title,style: TextStyle(fontSize: Screen.setFontSize(10),color: ColorConfig.WhiteBackColor),),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemTitle(String title) {
|
||||
return title.length == 0 ? Text('') : Container(
|
||||
margin: EdgeInsets.only(bottom: Screen.setFontSize(10)),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.ac_unit, color: ColorConfig.ThemeColor,size: Screen.setFontSize(16),),
|
||||
SizedBox(width: 5,),
|
||||
Text(title, style: TextStyle(fontSize: Screen.setFontSize(17),color: ColorConfig.TitleColor),)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ListItem({ ItemList data }) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 15),
|
||||
width: Screen.setWidth(172),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onLongPress: () => widget.longPress(data.id),
|
||||
onTap: () => Modular.to.pushNamed("/details/${data.id}"),
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(5)),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
elevation: 0,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: data.imgSrc,
|
||||
key: Key(data.id.toString()),
|
||||
height: Screen.setHeight(248),
|
||||
fit: BoxFit.cover,
|
||||
errorWidget:(context, url, error) => new Icon(Icons.error),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 10,
|
||||
child: TipsItem(title: data.shuliang.toString()),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onLongPress: () => widget.longPress(data.id),
|
||||
onTap: () => Modular.to.pushNamed("/details/${data.id}"),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: ColorConfig.TitleColor,fontSize: Screen.setFontSize(15)),),
|
||||
// Text(widget.data.user,style: TextStyle(color: ColorConfig.IconColor,fontSize: Screen.setFontSize(13))),
|
||||
data.jigoulist.isEmpty ? Text('') : Column(
|
||||
children: [
|
||||
Text(data.jigoulist[0].name,style: TextStyle(color: ColorConfig.IconColor,fontSize: Screen.setFontSize(13))),
|
||||
SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
data.biaoqianlist.isEmpty
|
||||
? Text("")
|
||||
: Wrap(
|
||||
spacing: 3,
|
||||
runSpacing: 2,
|
||||
children: data.biaoqianlist.map((v) => InkWell(
|
||||
onTap: () {
|
||||
Modular.to.pushNamed("/mechanismList/${v.id}/${v.name}/tags");
|
||||
},
|
||||
child: TipsItem(title: v.name),
|
||||
)).toList()
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return widget.data.isEmpty ? Container(
|
||||
height: MediaQuery.of(context).size.height / 2,
|
||||
child: Center(
|
||||
child: SpinKitWave(color: ColorConfig.ThemeColor, itemCount: 3, size: 40),
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
children: [
|
||||
GridView.builder(
|
||||
padding: EdgeInsets.only(left: 5,right: 5,top: 10),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 2 / 4.6,
|
||||
),
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemCount: widget.data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ListItem(
|
||||
data: widget.data[index]
|
||||
);
|
||||
}
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
103
untitled/lib/widget/ModelWidget.dart
Normal file
103
untitled/lib/widget/ModelWidget.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
import 'package:peach/entity/_.dart';
|
||||
|
||||
//// 模特item组件封装
|
||||
class ModelWidget extends StatelessWidget {
|
||||
|
||||
final List<Res> data;
|
||||
final String title;
|
||||
final double height;
|
||||
|
||||
ModelWidget({
|
||||
this.title,
|
||||
this.data,
|
||||
this.height: 0
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
// 如果标题没传,那么现实空,否则现实标题
|
||||
title == null
|
||||
? Text('')
|
||||
: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
margin: EdgeInsets.only(bottom: Screen.setFontSize(20),top: Screen.setFontSize(13),left: Screen.setFontSize(15)),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: Screen.setFontSize(17), color: ColorConfig.TitleColor,
|
||||
fontWeight: FontWeight.w400
|
||||
),
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
children: data.map((e) => Container(
|
||||
width: Screen.setWidth(75),
|
||||
margin: EdgeInsets.only(bottom: height),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Modular.to.pushNamed('/modelInfo/${e.id}/${e.title}');
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
ClipOval(
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: e.preview,
|
||||
width: Screen.setWidth(60),
|
||||
height: Screen.setWidth(60),
|
||||
fit: BoxFit.cover,
|
||||
errorWidget:(context, url, error) => new Icon(Icons.error),
|
||||
),
|
||||
),
|
||||
e.total.length == 0 ? Text("")
|
||||
: Positioned(
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: Screen.setFontSize(5),right: Screen.setFontSize(5),
|
||||
top: Screen.setFontSize(1),bottom: Screen.setFontSize(2)
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(0, 0, 0, 0.58),
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
),
|
||||
child: Text(
|
||||
e.total,
|
||||
style: TextStyle(
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
fontSize: Screen.setFontSize(11)
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: Screen.setHeight(3),),
|
||||
Text(
|
||||
e.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: ColorConfig.TextColor, fontSize: Screen.setFontSize(11)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
140
untitled/lib/widget/OldItemWidget.dart
Normal file
140
untitled/lib/widget/OldItemWidget.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:peach/entity/_.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
|
||||
class OldItemWidget extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ItemWidget();
|
||||
|
||||
List<HomeEntityData> data;
|
||||
String title;
|
||||
IconData icon;
|
||||
Function longPress;
|
||||
|
||||
OldItemWidget({
|
||||
this.data,
|
||||
this.title = "",
|
||||
this.icon,
|
||||
this.longPress,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class _ItemWidget extends State<OldItemWidget> {
|
||||
|
||||
|
||||
Widget TipsItem({ String title}) {
|
||||
return title == 'null' ? Text('') : Container(
|
||||
padding: EdgeInsets.only(top: 2,bottom: 2,left: 5,right: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConfig.ThemeColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
),
|
||||
child: Text(title,style: TextStyle(fontSize: Screen.setFontSize(10),color: ColorConfig.WhiteBackColor),),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: Screen.setFontSize(15),right: Screen.setFontSize(15),bottom: Screen.setFontSize(15)),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
// 标题
|
||||
widget.title.length == 0 ? Text('') : Container(
|
||||
margin: EdgeInsets.only(bottom: Screen.setFontSize(10)),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(widget.icon, color: ColorConfig.ThemeColor,size: Screen.setFontSize(16),),
|
||||
SizedBox(width: 5,),
|
||||
Text(widget.title, style: TextStyle(fontSize: Screen.setFontSize(17),color: ColorConfig.TitleColor),)
|
||||
],
|
||||
),
|
||||
),
|
||||
// 列表
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceAround,
|
||||
children: widget.data.map((e) =>Container(
|
||||
width: Screen.setWidth(172),
|
||||
margin: EdgeInsets.only(bottom: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onLongPress: () => widget.longPress(e.id),
|
||||
onTap: () => Modular.to.pushNamed("/details/${e.id}"),
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(5)),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
elevation: 0,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: e.preview,
|
||||
key: Key(e.id.toString()),
|
||||
height: Screen.setHeight(248),
|
||||
fit: BoxFit.cover,
|
||||
errorWidget:(context, url, error) => new Icon(Icons.error),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 10,
|
||||
child: TipsItem(title: e.total.toString()),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onLongPress: () => widget.longPress(e.id),
|
||||
onTap: () => Modular.to.pushNamed("/details/${e.id}"),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(e.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: ColorConfig.TitleColor,fontSize: Screen.setFontSize(15)),),
|
||||
Text(e.user,style: TextStyle(color: ColorConfig.IconColor,fontSize: Screen.setFontSize(13))),
|
||||
e.source.length == 0 ? Text('') : Column(
|
||||
children: [
|
||||
Text(e.source,style: TextStyle(color: ColorConfig.IconColor,fontSize: Screen.setFontSize(13))),
|
||||
SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
e.tags == null
|
||||
? Text("")
|
||||
: Wrap(
|
||||
spacing: 3,
|
||||
runSpacing: 2,
|
||||
children: e.tags.map((v) => InkWell(
|
||||
onTap: () {
|
||||
Modular.to.pushNamed("/mechanismList/${v.id}/${v.title}/tags");
|
||||
},
|
||||
child: TipsItem(title: v.title),
|
||||
)).toList()
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)).toList(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
119
untitled/lib/widget/PhotoViewGalleryScreen.dart
Normal file
119
untitled/lib/widget/PhotoViewGalleryScreen.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
|
||||
class PhotoViewGalleryScreen extends StatefulWidget {
|
||||
List<String> images = [];
|
||||
int index = 0;
|
||||
String heroTag;
|
||||
String title;
|
||||
String time;
|
||||
PageController controller;
|
||||
|
||||
PhotoViewGalleryScreen({
|
||||
Key key,
|
||||
@required this.images,
|
||||
this.index,
|
||||
this.title = "",
|
||||
this.time = "",
|
||||
this.controller,
|
||||
this.heroTag
|
||||
}) : super(key: key) {
|
||||
controller = PageController(initialPage: index);
|
||||
}
|
||||
|
||||
@override
|
||||
_PhotoViewGalleryScreenState createState() => _PhotoViewGalleryScreenState();
|
||||
}
|
||||
|
||||
class _PhotoViewGalleryScreenState extends State<PhotoViewGalleryScreen> {
|
||||
int currentIndex = 0;
|
||||
// String dropdownValue = '请选择';
|
||||
// List<String> settingList = ['请选择', '设置壁纸','设置锁屏','同时设置'];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
currentIndex = widget.index;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
color: Colors.black,
|
||||
child: PhotoViewGallery.builder(
|
||||
scrollPhysics: const BouncingScrollPhysics(),
|
||||
builder: (BuildContext context, int index) {
|
||||
return PhotoViewGalleryPageOptions(
|
||||
imageProvider: NetworkImage(widget.images[index]),
|
||||
heroAttributes: widget.heroTag.isNotEmpty
|
||||
? PhotoViewHeroAttributes(tag: widget.heroTag)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
itemCount: widget.images.length,
|
||||
backgroundDecoration: null,
|
||||
pageController: widget.controller,
|
||||
enableRotation: true,
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
currentIndex = index;
|
||||
});
|
||||
},
|
||||
)),
|
||||
),
|
||||
Positioned(
|
||||
//图片index显示
|
||||
top: MediaQuery.of(context).padding.top + 15,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: Text("${currentIndex + 1}P / ${widget.images.length}P",
|
||||
style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: MediaQuery.of(context).padding.top + 15,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 15,right: 5),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(widget.title,style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
SizedBox(height: 5,),
|
||||
Text(widget.time,style: TextStyle(color: ColorConfig.TextColor, fontSize: 12))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
//右上角关闭按钮
|
||||
right: 10,
|
||||
top: MediaQuery.of(context).padding.top,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
size: 30,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
Modular.to.pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
48
untitled/lib/widget/SwiperWidget.dart
Normal file
48
untitled/lib/widget/SwiperWidget.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_swiper/flutter_swiper.dart';
|
||||
import 'package:peach/config/_.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
|
||||
/// 轮播图组件的封装
|
||||
class SwiperWidget extends StatelessWidget {
|
||||
List<Widget> child;
|
||||
double width;
|
||||
double height;
|
||||
bool autoplay;
|
||||
int autoplayDelay;
|
||||
|
||||
SwiperWidget({
|
||||
@required this.child,
|
||||
this.width: double.infinity,
|
||||
this.height: 130,
|
||||
this.autoplay: true,
|
||||
this.autoplayDelay: 3000,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
height: height,
|
||||
width: width,
|
||||
child: Swiper(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
//条目构建函数传入了index,根据index索引到特定图片
|
||||
return child[index];
|
||||
},
|
||||
itemCount: child.length != 0 ? child.length : 0,
|
||||
autoplay: autoplay,
|
||||
autoplayDelay: autoplayDelay,
|
||||
pagination: new SwiperPagination(
|
||||
builder: DotSwiperPaginationBuilder(
|
||||
size: Screen.setFontSize(7),
|
||||
activeSize: Screen.setFontSize(7),
|
||||
color: ColorConfig.TextColor,
|
||||
activeColor: ColorConfig.ThemeColor,
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
10
untitled/lib/widget/_.dart
Normal file
10
untitled/lib/widget/_.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
library widget;
|
||||
|
||||
export 'CellWidget.dart';
|
||||
export 'ModelWidget.dart';
|
||||
export 'SwiperWidget.dart';
|
||||
export 'ItemWidget.dart';
|
||||
export 'OldItemWidget.dart';
|
||||
export 'FutureBuilderWidget.dart';
|
||||
export 'PhotoViewGalleryScreen.dart';
|
||||
export 'CachedNetworkImage.dart';
|
||||
Reference in New Issue
Block a user