diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index d802ea4..0cdc362 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,27 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml
index fb5a613..d99782f 100644
--- a/.idea/libraries/Flutter_Plugins.xml
+++ b/.idea/libraries/Flutter_Plugins.xml
@@ -1,10 +1,10 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index aa24c60..8c57911 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,18 +6,16 @@
-
+
+
-
-
-
@@ -51,18 +49,6 @@
-
-
-
@@ -90,9 +76,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b82af4..e266bb3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.3.1
+
+1.图片长按回调图片位置
+
+2.修复图片显示错位bug
+
## 1.3.0
1.增加查看图片长按事件回调
diff --git a/README.md b/README.md
index 2e79456..f5fe2ae 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,12 @@ dependencies:
# 版本更新
+## 1.3.1
+
+1.图片长按回调图片位置
+
+2.修复图片显示错位bug
+
## 1.3.0
1.增加查看图片长按事件回调
@@ -87,19 +93,18 @@ class _MyHomePageState extends State {
),
body: Container(
child: NineOldWidget(
- images: images[count],
- onLongPressListener: () {
+ images: images[count],//必填
+ onLongPressListener: (position) {//可选
//长按事件回调
- print("长按事件回调");
+ print("长按事件回调当前位置 : $position");
},
- backgroundColor: Colors.grey,//加载背景颜色
- valueColor: Colors.blue,//加载进度条颜色
- strokeWidth: 4,//加载进度条宽度
- moreStyle: TextStyle(
- fontSize: 14,
- color: Colors.orange
- ),//更多加号样式
-
+ backgroundColor: Colors.white,//可选
+ //加载背景颜色
+ valueColor: Colors.red,//可选
+ //加载进度条颜色
+ strokeWidth: 4,//可选
+ //加载进度条宽度
+ moreStyle: TextStyle(fontSize: 28, color: Colors.orange), //更多加号样式
),
),
floatingActionButton: FloatingActionButton(
@@ -117,6 +122,20 @@ class _MyHomePageState extends State {
```
+NineOldWidget控件构造方法以及参数设置
+
+```
+ NineOldWidget(
+ {@required this.images,
+ this.moreStyle,
+ this.backgroundColor = Colors.white,
+ this.strokeWidth = 3,
+ this.valueColor = Colors.tealAccent,
+ this.onLongPressListener});
+```
+
+
+
### 使用说明
NineOldWidget 是用来封装图片九宫格显示的组件, 方便使用者能更好的使用该插件. 使用者只要需要注入图片集合,集成和Photo_view的Hero动画以及网络图片加载的展位图进度显示,就可以实现图片查看,九宫格列表
diff --git a/example/lib/main.dart b/example/lib/main.dart
index be40f58..77833fa 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -50,8 +50,6 @@ class _MyHomePageState extends State {
"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2417108265,1198830140&fm=26&gp=0.jpg");
list.add(
"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=244450851,2728981198&fm=26&gp=0.jpg");
- list.add(
- "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=882251069,3759945909&fm=11&gp=0.jpg");
list.add(
"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2083759825,3454063564&fm=26&gp=0.jpg");
list.add(
@@ -64,6 +62,8 @@ class _MyHomePageState extends State {
"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3153722339,140981551&fm=26&gp=0.jpg");
list.add(
"https://t8.baidu.com/it/u=3571592872,3353494284&fm=79&app=86&size=h300&n=0&g=4n&f=jpeg?sec=1584605109&t=4c346851d3f4f4cf76439fe6440ffe9f");
+ list.add(
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594817167403&di=87226dc3d6b70a7e02722b9f9bd9f33a&imgtype=0&src=http%3A%2F%2Ft9.baidu.com%2Fit%2Fu%3D1307125826%2C3433407105%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D5760%26h%3D3240");
return list;
}
@@ -75,19 +75,18 @@ class _MyHomePageState extends State {
),
body: Container(
child: NineOldWidget(
- images: images[count],
- onLongPressListener: () {
+ images: images[count],//必填
+ onLongPressListener: (position) {//可选
//长按事件回调
- print("长按事件回调");
+ print("长按事件回调当前位置 : $position");
},
- backgroundColor: Colors.white,//加载背景颜色
- valueColor: Colors.red,//加载进度条颜色
- strokeWidth: 4,//加载进度条宽度
- moreStyle: TextStyle(
- fontSize: 28,
- color: Colors.orange
- ),//更多加号样式
-
+ backgroundColor: Colors.white,//可选
+ //加载背景颜色
+ valueColor: Colors.red,//可选
+ //加载进度条颜色
+ strokeWidth: 4,//可选
+ //加载进度条宽度
+ moreStyle: TextStyle(fontSize: 28, color: Colors.orange), //更多加号样式
),
),
floatingActionButton: FloatingActionButton(
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 5538e2f..9fe4afa 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -150,7 +150,7 @@ packages:
path: ".."
relative: true
source: path
- version: "1.2.0"
+ version: "1.3.0"
path:
dependency: transitive
description:
diff --git a/lib/loader/image_with_loader.dart b/lib/loader/image_with_loader.dart
index d3a71b0..8c7f499 100644
--- a/lib/loader/image_with_loader.dart
+++ b/lib/loader/image_with_loader.dart
@@ -3,12 +3,12 @@ import 'package:transparent_image/transparent_image.dart';
class ImageWithLoader extends StatelessWidget {
const ImageWithLoader(
- {this.url,
+ {@required this.url,
+ @required this.backgroundColor,
+ @required this.strokeWidth,
+ @required this.valueColor,
this.fit = BoxFit.cover,
- this.loaderSize = 48.0,
- this.backgroundColor = Colors.white,
- this.strokeWidth = 3,
- this.valueColor = Colors.tealAccent});
+ this.loaderSize = 48.0});
final String url;
final BoxFit fit;
@@ -31,9 +31,9 @@ class ImageWithLoader extends StatelessWidget {
width: loaderSize,
height: loaderSize,
child: _buildCircularProgressIndicator(
- backgroundColor: backgroundColor,
- strokeWidth: strokeWidth,
- valueColor: valueColor),
+ cpBackgroundColor: backgroundColor,
+ cpStrokeWidth: strokeWidth,
+ cpValueColor: valueColor),
),
),
),
@@ -48,10 +48,10 @@ class ImageWithLoader extends StatelessWidget {
}
CircularProgressIndicator _buildCircularProgressIndicator(
- {Color backgroundColor, double strokeWidth, Color valueColor}) {
+ {Color cpBackgroundColor, double cpStrokeWidth, Color cpValueColor}) {
return CircularProgressIndicator(
- backgroundColor: backgroundColor,
- strokeWidth: strokeWidth,
- valueColor: AlwaysStoppedAnimation(valueColor),
+ backgroundColor: cpBackgroundColor,
+ strokeWidth: cpStrokeWidth,
+ valueColor: AlwaysStoppedAnimation(cpValueColor),
);
}
diff --git a/lib/watcher/gallery_watcher.dart b/lib/watcher/gallery_watcher.dart
index 0a4588f..faca044 100644
--- a/lib/watcher/gallery_watcher.dart
+++ b/lib/watcher/gallery_watcher.dart
@@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
-typedef OnLongPressCallback = void Function();
-
+typedef OnLongPressCallback = void Function(int position);
class GalleryPhotoViewWrapper extends StatefulWidget {
GalleryPhotoViewWrapper({
@@ -31,7 +30,6 @@ class GalleryPhotoViewWrapper extends StatefulWidget {
final OnLongPressCallback onLongPressListener;
-
@override
State createState() {
return _GalleryPhotoViewWrapperState();
@@ -62,7 +60,11 @@ class _GalleryPhotoViewWrapperState extends State {
height: MediaQuery.of(context).size.height,
),
child: InkWell(
- onLongPress: widget.onLongPressListener,
+ onLongPress: () {
+ if (null != widget.onLongPressListener) {
+ widget.onLongPressListener(currentIndex);
+ }
+ },
child: Stack(
alignment: Alignment.bottomRight,
children: [
diff --git a/lib/widget/nine_old_widget.dart b/lib/widget/nine_old_widget.dart
index 7110721..81f8389 100644
--- a/lib/widget/nine_old_widget.dart
+++ b/lib/widget/nine_old_widget.dart
@@ -13,11 +13,11 @@ class NineOldWidget extends StatelessWidget {
final OnLongPressCallback onLongPressListener;
NineOldWidget(
- {this.images,
+ {@required this.images,
this.moreStyle,
- this.backgroundColor,
- this.strokeWidth,
- this.valueColor,
+ this.backgroundColor = Colors.white,
+ this.strokeWidth = 3,
+ this.valueColor = Colors.tealAccent,
this.onLongPressListener});
double width;
diff --git a/pubspec.yaml b/pubspec.yaml
index 34fba26..fe03918 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: nineold
description: Nineoldwidget is a component used to encapsulate the nine palace display of pictures.
-version: 1.3.0
+version: 1.3.1
homepage: https://github.com/lanzhu1993/flutter_nineold
environment: