Skip to content

Commit

Permalink
Merge pull request #18 from PicGo/dev
Browse files Browse the repository at this point in the history
build:build 1.9.2+24
  • Loading branch information
hackycy authored Dec 30, 2020
2 parents 8795c60 + b01bf49 commit 03dbf3a
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 481 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<blockquote>图片上传+管理新体验 </blockquote>
<img src="https://img.shields.io/github/license/hackycy/flutter-picgo" alt="">
<img src="https://img.shields.io/github/workflow/status/hackycy/flutter-picgo/Build and Release apk" alt="">
<img src="https://img.shields.io/github/repo-size/hackycy/flutter-picgo" alt="">
<img src="https://img.shields.io/github/v/release/hackycy/flutter-picgo" alt="">
<img src="https://img.shields.io/github/issues-closed/hackycy/flutter-picgo" alt="">
<img src="https://img.shields.io/github/v/release/hackycy/flutter-picgo?include_prereleases" alt="">
<img src="https://img.shields.io/github/downloads/hackycy/flutter-picgo/total" alt="">
</div>

Expand Down
4 changes: 2 additions & 2 deletions docs/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"versionCode": "22"
},
"Android": {
"versionName": "1.9.1",
"versionCode": "22"
"versionName": "1.9.2",
"versionCode": "23"
}
}
1 change: 0 additions & 1 deletion lib/components/upload_item/upload_item_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_picgo/utils/image_upload.dart';
import 'package:flutter_picgo/utils/strategy/upload_strategy_factory.dart';

Expand Down
6 changes: 0 additions & 6 deletions lib/routers/router_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'package:flutter_picgo/views/pb_setting_page/tcyun_page/tcyun_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/upyun_page/upyun_page.dart';
import 'package:flutter_picgo/views/picgo_setting_page/theme_setting_page.dart';
import 'package:flutter_picgo/views/upload_page/handle_upload_page.dart';
import 'package:flutter_picgo/views/upload_page/upload_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/github_page/github_page.dart';
import 'package:flutter_picgo/views/picgo_setting_page/picgo_setting_page.dart';
import 'package:flutter_picgo/views/setting_page/setting_page.dart';
Expand Down Expand Up @@ -56,11 +55,6 @@ var settingHandler = new Handler(
);

// 上传页面
var uploadHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) =>
UploadPage(),
);

var preUploadHandler = new Handler(
handlerFunc: (context, parameters) {
final assets = context.settings.arguments as List<AssetEntity>;
Expand Down
1 change: 0 additions & 1 deletion lib/routers/routers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Routes {
router.define(root, handler: appHandler);
router.define(notfound, handler: notfoundHandler);
router.define(album, handler: albumHandler);
router.define(upload, handler: uploadHandler);
router.define(handleUpload, handler: preUploadHandler);
router.define(setting, handler: settingHandler);
router.define(settingPb, handler: pbsettingHandler);
Expand Down
1 change: 0 additions & 1 deletion lib/utils/db_provider.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter_picgo/resources/pb_type_keys.dart';
import 'package:flutter_picgo/resources/table_name_keys.dart';
import 'package:sqflite/sqflite.dart';
Expand Down
156 changes: 101 additions & 55 deletions lib/utils/image_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import 'dart:math';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_picgo/model/uploaded.dart';
import 'package:flutter_picgo/utils/extended.dart';
import 'package:toast/toast.dart';

class ImagePreviewUtils {
/// 打开图片预览页面
static void open(BuildContext context, String content) {
var item = new GalleryItem(id: '0', resource: '$content');
static void open(BuildContext context, Uploaded content) {
var page = GalleryPhotoViewWrapper(
galleryItems: [item],
galleryItems: [content],
);
Navigator.push(
context,
Expand All @@ -22,8 +22,7 @@ class ImagePreviewUtils {
);
}

static void openMulti(
BuildContext context, int index, List<GalleryItem> items) {
static void openMulti(BuildContext context, int index, List<Uploaded> items) {
var page = GalleryPhotoViewWrapper(
galleryItems: items,
initialIndex: index,
Expand All @@ -36,16 +35,9 @@ class ImagePreviewUtils {
}
}

class GalleryItem {
GalleryItem({this.id, this.resource});

final String id;
final String resource;
}

class GalleryPhotoViewWrapper extends StatefulWidget {
final int initialIndex;
final List<GalleryItem> galleryItems;
final List<Uploaded> galleryItems;

GalleryPhotoViewWrapper({
this.initialIndex = 0,
Expand Down Expand Up @@ -85,44 +77,67 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
color: Colors.black,
pageGestureAxis: SlideAxis.both),
child: GestureDetector(
child: ExtendedImageGesturePageView.builder(
itemBuilder: (BuildContext context, int index) {
var item = widget.galleryItems[index];
Widget image = item.resource.startsWith('http')
? ExtendedImage.network(
item.resource,
fit: BoxFit.contain,
cache: true,
mode: ExtendedImageMode.gesture,
enableSlideOutPage: true,
loadStateChanged: (state) =>
defaultLoadStateChanged(state, iconSize: 50),
)
: ExtendedImage.file(
File(item.resource),
fit: BoxFit.contain,
mode: ExtendedImageMode.gesture,
enableSlideOutPage: true,
loadStateChanged: (state) =>
defaultLoadStateChanged(state, iconSize: 50),
child: Stack(
// fit: StackFit.expand,
alignment: Alignment.bottomRight,
children: [
ExtendedImageGesturePageView.builder(
itemBuilder: (BuildContext context, int index) {
var item = widget.galleryItems[index];
Widget image = item.path.startsWith('http')
? ExtendedImage.network(
item.path,
fit: BoxFit.contain,
cache: true,
mode: ExtendedImageMode.gesture,
enableSlideOutPage: true,
loadStateChanged: (state) =>
defaultLoadStateChanged(state, iconSize: 50),
)
: ExtendedImage.file(
File(item.path),
fit: BoxFit.contain,
mode: ExtendedImageMode.gesture,
enableSlideOutPage: true,
loadStateChanged: (state) =>
defaultLoadStateChanged(state, iconSize: 50),
);
image = Container(
child: image,
);
if (index == currentIndex) {
return Hero(
tag: index,
child: image,
);
image = Container(
child: image,
);
if (index == currentIndex) {
return Hero(
tag: index,
child: image,
);
} else {
return image;
}
},
itemCount: widget.galleryItems.length,
controller: PageController(
initialPage: currentIndex,
),
scrollDirection: Axis.horizontal,
} else {
return image;
}
},
itemCount: widget.galleryItems.length,
controller: PageController(
initialPage: currentIndex,
),
onPageChanged: onPageChanged,
scrollDirection: Axis.horizontal,
),
SafeArea(
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(4)),
color: Colors.grey),
padding: EdgeInsets.fromLTRB(5, 2, 5, 2),
child: Text(
'${currentIndex + 1} / ${widget.galleryItems.length}',
style: TextStyle(
color: Colors.white,
decoration: TextDecoration.none,
fontWeight: FontWeight.normal,
fontSize: 10),
),
))
],
),
onLongPress: () {
_showBottomPane();
Expand All @@ -142,9 +157,41 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text('复制链接'),
title: Text(
'图床类型',
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(widget.galleryItems[currentIndex].type),
),
ListTile(
title: Text(
'图片链接',
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(widget.galleryItems[currentIndex].path),
onTap: () {
_handleCopy(
widget.galleryItems[currentIndex].path, context);
},
),
ListTile(
title: Text(
'图片信息',
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(widget.galleryItems[currentIndex].info),
onTap: () {
_handleCopy(
widget.galleryItems[currentIndex].info, context);
},
),
ListTile(
title: Text(
'取消',
style: TextStyle(fontWeight: FontWeight.bold),
),
onTap: () {
_handleCopy(context);
Navigator.pop(context);
},
),
],
Expand All @@ -154,9 +201,8 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
}

/// 复制链接
_handleCopy(BuildContext context) {
Clipboard.setData(
ClipboardData(text: widget.galleryItems[currentIndex].resource));
_handleCopy(String content, BuildContext context) {
Clipboard.setData(ClipboardData(text: content));
Toast.show('已复制到剪切板', context);
Navigator.pop(context);
}
Expand Down
1 change: 0 additions & 1 deletion lib/utils/local_notification.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';

class LocalNotificationUtil {
Expand Down
1 change: 0 additions & 1 deletion lib/utils/strategy/impl/tcyun_image_upload.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_picgo/api/tcyun_api.dart';
import 'package:flutter_picgo/model/tcyun_config.dart';
import 'package:flutter_picgo/model/uploaded.dart';
Expand Down
7 changes: 1 addition & 6 deletions lib/views/album_page/album_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,7 @@ class _AlbumPageState extends State<AlbumPage> implements AlbumPageContract {

/// 处理图片点击事件
handleTap(int index) {
ImagePreviewUtils.openMulti(
context,
index,
_uploadeds.map((e) {
return GalleryItem(id: e.id.toString(), resource: e.path);
}).toList());
ImagePreviewUtils.openMulti(context, index, _uploadeds);
}

/// 处理图片双击
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter_picgo/api/qiniu_api.dart';
import 'package:flutter_picgo/components/manage_item.dart';
import 'package:flutter_picgo/model/qiniu_config.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/views/pb_setting_page/pb_setting_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_picgo/model/pb_setting.dart';
import 'package:flutter_picgo/resources/table_name_keys.dart';
import 'package:flutter_picgo/utils/image_upload.dart';
Expand Down
26 changes: 22 additions & 4 deletions lib/views/picgo_setting_page/picgo_setting_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:extended_image/extended_image.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -120,10 +121,6 @@ class _PicGoSettingPageState extends State<PicGoSettingPage> {
transition: TransitionType.cupertino);
},
),
// ListTile(
// title: Text('设置显示图床'),
// onTap: () {},
// ),
ListTile(
title: Text('版本更新'),
onTap: () {
Expand All @@ -141,6 +138,12 @@ class _PicGoSettingPageState extends State<PicGoSettingPage> {
),
),
),
ListTile(
title: Text('清除缓存'),
onTap: () {
_handleClearCache();
},
)
],
);
},
Expand Down Expand Up @@ -181,4 +184,19 @@ class _PicGoSettingPageState extends State<PicGoSettingPage> {
launch('https://apps.apple.com/cn/app/flutter-picgo/id1519714305');
}
}

/// 清空缓存
_handleClearCache() async {
/// extended_image
try {
bool clear = await clearDiskCachedImages();
if (clear) {
Toast.show('清除成功', context);
} else {
throw ('clear fail');
}
} catch (e) {
Toast.show('清除失败', context);
}
}
}
7 changes: 3 additions & 4 deletions lib/views/upload_page/handle_upload_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:math';
import 'package:flutter_picgo/components/upload_item/upload_item.dart';
import 'package:flutter_picgo/utils/strings.dart';
import 'package:path/path.dart' as path;
Expand Down Expand Up @@ -116,15 +115,15 @@ class _HandleUploadPageState extends State<HandleUploadPage> {
sp.getBool(SharedPreferencesKeys.settingIsTimestampRename) ?? false;

if (settingIsTimestampRename) {
int timestamp = new DateTime.now().millisecondsSinceEpoch;

/// 处理时间戳命名
var random = Random();
for (int i = 0; i < widget.assets.length; i++) {
/// 获取图片名
String suffix = path.extension(tmp.path);

/// replace
filesName[i] =
'${new DateTime.now().millisecondsSinceEpoch.toString()}-${random.nextInt(100)}$suffix';
filesName[i] = '${timestamp + i}$suffix';
}
}
var settingIsUploadedRename =
Expand Down
Loading

0 comments on commit 03dbf3a

Please sign in to comment.