From d3f84781e3d3b9667f112874599f3d7a46c5377a Mon Sep 17 00:00:00 2001 From: perol Date: Sat, 23 Jan 2021 18:20:57 +0800 Subject: [PATCH] upgrade lib --- lib/network/compute_interceptor.dart | 1 - lib/page/about/iap_store.dart | 11 +- lib/page/hello/android_hello_page.dart | 5 +- .../novel/component/novel_lighting_store.dart | 2 +- lib/page/picture/illust_lighting_page.dart | 2 +- lib/page/picture/illust_page.dart | 814 ------------------ lib/page/picture/ugoira_loader.dart | 24 - lib/page/user/user_page.dart | 145 ---- lib/page/webview/webview_spotlight_page.dart | 189 ---- pubspec.lock | 29 +- pubspec.yaml | 11 +- 11 files changed, 13 insertions(+), 1220 deletions(-) delete mode 100644 lib/page/picture/illust_page.dart delete mode 100644 lib/page/user/user_page.dart delete mode 100644 lib/page/webview/webview_spotlight_page.dart diff --git a/lib/network/compute_interceptor.dart b/lib/network/compute_interceptor.dart index 439c3497b..7a66ddb2d 100644 --- a/lib/network/compute_interceptor.dart +++ b/lib/network/compute_interceptor.dart @@ -13,7 +13,6 @@ * this program. If not, see . */ import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; class ComputeInterceptor extends Interceptor { @override diff --git a/lib/page/about/iap_store.dart b/lib/page/about/iap_store.dart index cf14f3237..1ea3614c7 100644 --- a/lib/page/about/iap_store.dart +++ b/lib/page/about/iap_store.dart @@ -3,7 +3,6 @@ import 'dart:core'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart'; import 'package:mobx/mobx.dart'; import 'package:pixez/er/lprinter.dart'; @@ -17,7 +16,7 @@ abstract class _IAPStoreBase with Store { dispose() { _purchaseErrorSubscription?.cancel(); - _purchaseErrorSubscription?.cancel(); + _purchaseUpdatedSubscription?.cancel(); } StreamSubscription _purchaseUpdatedSubscription; @@ -26,8 +25,6 @@ abstract class _IAPStoreBase with Store { Future initPlatformState() async { var result = await FlutterInappPurchase.instance.initConnection; print('result: $result'); - List iaps = - await FlutterInappPurchase.instance.getProducts(_productLists); try { List msg = await FlutterInappPurchase.instance .getProducts(['support', 'support1']); @@ -53,12 +50,6 @@ abstract class _IAPStoreBase with Store { @action Future initAndroidIap() async { - String platformVersion; - try { - platformVersion = await FlutterInappPurchase.instance.platformVersion; - } on PlatformException { - platformVersion = 'Failed to get platform version.'; - } var result = await FlutterInappPurchase.instance.initConnection; print('result: $result'); try { diff --git a/lib/page/hello/android_hello_page.dart b/lib/page/hello/android_hello_page.dart index ea5ffad95..3ad4f48cc 100644 --- a/lib/page/hello/android_hello_page.dart +++ b/lib/page/hello/android_hello_page.dart @@ -152,9 +152,7 @@ class _AndroidHelloPageState extends State { try { Uri initialLink = await getInitialUri(); if (initialLink != null) Leader.pushWithUri(context, initialLink); - _sub = getUriLinksStream().listen((Uri link) { - Leader.pushWithUri(context, link); - }); + _sub = getUriLinksStream().listen((Uri link) => Leader.pushWithUri(context, link)); } catch (e) { print(e); } @@ -207,6 +205,7 @@ class _AndroidHelloPageState extends State { void dispose() { _intentDataStreamSubscription?.cancel(); _pageController?.dispose(); + _sub?.cancel(); super.dispose(); } diff --git a/lib/page/novel/component/novel_lighting_store.dart b/lib/page/novel/component/novel_lighting_store.dart index 71b22c5ce..f98713a44 100644 --- a/lib/page/novel/component/novel_lighting_store.dart +++ b/lib/page/novel/component/novel_lighting_store.dart @@ -64,7 +64,7 @@ abstract class _NovelLightingStoreBase with Store { } @action - Future next() async { + Future next() async { if (nextUrl != null && nextUrl.isNotEmpty) { try { Response response = await _client.getNext(nextUrl); diff --git a/lib/page/picture/illust_lighting_page.dart b/lib/page/picture/illust_lighting_page.dart index 727c3567a..45c37298b 100644 --- a/lib/page/picture/illust_lighting_page.dart +++ b/lib/page/picture/illust_lighting_page.dart @@ -691,7 +691,7 @@ class _IllustLightingPageState extends State }); } - Future _pressSave(Illusts illust, int index) { + Future _pressSave(Illusts illust, int index) async { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( diff --git a/lib/page/picture/illust_page.dart b/lib/page/picture/illust_page.dart deleted file mode 100644 index cb28fa495..000000000 --- a/lib/page/picture/illust_page.dart +++ /dev/null @@ -1,814 +0,0 @@ -/* - * Copyright (C) 2020. by perol_notsf, All rights reserved - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - */ - -import 'package:bot_toast/bot_toast.dart'; -import 'package:dio/dio.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:pixez/component/ban_page.dart'; -import 'package:pixez/component/painter_avatar.dart'; -import 'package:pixez/component/pixiv_image.dart'; -import 'package:pixez/component/star_icon.dart'; -import 'package:pixez/exts.dart'; -import 'package:pixez/generated/l10n.dart'; -import 'package:pixez/main.dart'; -import 'package:pixez/models/ban_illust_id.dart'; -import 'package:pixez/models/bookmark_detail.dart'; -import 'package:pixez/models/illust.dart'; -import 'package:pixez/network/api_client.dart'; -import 'package:pixez/page/picture/illust_about_grid.dart'; -import 'package:pixez/page/picture/illust_detail_body.dart'; -import 'package:pixez/page/picture/illust_detail_store.dart'; -import 'package:pixez/page/picture/illust_store.dart'; -import 'package:pixez/page/picture/ugoira_loader.dart'; -import 'package:pixez/page/zoom/photo_viewer_page.dart'; -import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; -import 'package:share/share.dart'; - -class IllustPage extends StatefulWidget { - final int id; - final String heroString; - final IllustStore store; - - const IllustPage({Key key, @required this.id, this.store, this.heroString}) - : super(key: key); - - @override - _IllustPageState createState() => _IllustPageState(); -} - -class _IllustPageState extends State { - IllustStore _illustStore; - final ItemScrollController itemScrollController = ItemScrollController(); - final ItemPositionsListener itemPositionsListener = - ItemPositionsListener.create(); - - @override - void initState() { - _illustStore = widget.store ?? IllustStore(widget.id, null); - _illustStore.fetch(); - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - Future _showBookMarkTag() async { - if (_illustStore.isBookmark) { - await _illustStore.star(); - setState(() {}); - return; - } - CancelFunc cancelFunc = - BotToast.showLoading(clickClose: true, allowClick: true); - Response response; - try { - response = await apiClient.getIllustBookmarkDetail(widget.id); - cancelFunc(); - } catch (e) { - cancelFunc(); - return; - } - BookMarkDetailResponse bookMarkDetailResponse = - BookMarkDetailResponse.fromJson(response.data); - if (mounted) - showDialog( - context: context, - child: StatefulBuilder( - builder: (_, setBookState) { - final TextEditingController textEditingController = - TextEditingController(); - final List tags = - bookMarkDetailResponse.bookmarkDetail.tags; - final detail = bookMarkDetailResponse.bookmarkDetail; - return AlertDialog( - contentPadding: EdgeInsets.all(2.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0))), - content: Container( - width: double.maxFinite, - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - TextField( - controller: textEditingController, - decoration: InputDecoration( - suffixIcon: IconButton( - icon: Icon(Icons.add), - onPressed: () { - final value = - textEditingController.value.text.trim(); - if (value.isNotEmpty) - setBookState(() { - tags.insert( - 0, - TagsR() - ..name = value - ..isRegistered = true); - textEditingController.clear(); - }); - }, - )), - ), - Expanded( - child: ListView.builder( - padding: EdgeInsets.all(0.0), - itemCount: tags.length, - itemBuilder: (BuildContext context, int index) { - return Flex( - direction: Axis.horizontal, - children: [ - Expanded( - child: Text( - bookMarkDetailResponse - .bookmarkDetail.tags[index].name, - softWrap: true, - maxLines: 1, - textAlign: TextAlign.left, - overflow: TextOverflow.ellipsis, - ), - ), - Checkbox( - onChanged: (bool value) { - setBookState(() { - bookMarkDetailResponse.bookmarkDetail - .tags[index].isRegistered = value; - }); - }, - value: bookMarkDetailResponse - .bookmarkDetail.tags[index].isRegistered, - ) - ], - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - ); - }, - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text((detail.restrict == "public" - ? I18n.of(context).public - : I18n.of(context).private) + - I18n.of(context).bookmark), - ), - Switch( - onChanged: (bool value) { - setBookState(() { - detail.restrict = value ? "public" : "private"; - }); - }, - value: detail.restrict == "public", - ) - ], - ) - ], - ), - ), - actions: [ - FlatButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text(I18n.of(context).cancel)), - FlatButton( - child: Text(I18n.of(context).ok), - onPressed: () async { - final tags = bookMarkDetailResponse.bookmarkDetail.tags; - List tempTags = []; - for (int i = 0; i < tags.length; i++) { - if (tags[i].isRegistered) { - tempTags.add(tags[i].name); - } - } - if (tempTags.length == 0) tempTags = null; - Navigator.of(context).pop(); - await _illustStore.star( - restrict: - bookMarkDetailResponse.bookmarkDetail.restrict, - tags: tempTags); - - setState(() {}); //star请求不管成功或是失败都强刷一次外层ui,因为mobx影响不到 - }, - ), - ], - ); - }, - )); - } - - Widget _buildNameAvatar(BuildContext context, Illusts illust) { - IllustDetailStore illustDetailStore = IllustDetailStore(illust); - return Observer(builder: (_) { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - child: GestureDetector( - onLongPress: () { - illustDetailStore.followUser(); - }, - child: Container( - height: 70, - width: 70, - child: Stack( - children: [ - Center( - child: SizedBox( - height: 70, - width: 70, - child: Container( - decoration: illust != null - ? BoxDecoration( - shape: BoxShape.circle, - color: illustDetailStore.isFollow - ? Colors.yellow - : Theme.of(context).accentColor, - ) - : BoxDecoration(), - ), - ), - ), - Center( - child: PainterAvatar( - url: illust.user.profileImageUrls.medium, - id: illust.user.id, - ), - ), - ], - ), - ), - ), - padding: EdgeInsets.all(8.0)), - Expanded( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SelectableText( - illust.title, - style: TextStyle(color: Theme.of(context).accentColor), - ), - Container( - height: 4.0, - ), - SelectableText( - illust.user.name, - style: Theme.of(context).textTheme.bodyText2, - ), - Text( - illust.createDate.toShortTime(), - style: Theme.of(context).textTheme.caption, - ), - ], - ), - ), - ), - ], - ); - }); - } - - Future buildShowModalBottomSheet(BuildContext context, Illusts illusts) { - return showModalBottomSheet( - isScrollControlled: true, - context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(16), - ), - ), - builder: (_) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8.0), - topRight: Radius.circular(8.0))), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.min, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - _buildNameAvatar(context, illusts), - if (illusts.metaPages.isNotEmpty) - ListTile( - title: Text(I18n.of(context).muti_choice_save), - leading: Icon( - Icons.save, - ), - onTap: () async { - Navigator.of(context).pop(); - _showMutiChoiceDialog(illusts, context); - }, - ), - ListTile( - title: Text(I18n.of(context).copymessage), - leading: Icon( - Icons.local_library, - ), - onTap: () async { - await Clipboard.setData(ClipboardData( - text: - 'title:${illusts.title}\npainter:${illusts.user.name}\nillust id:${widget.id}')); - BotToast.showText( - text: I18n.of(context).copied_to_clipboard); - Navigator.of(context).pop(); - }, - ), - ListTile( - title: Text(I18n.of(context).share), - leading: Icon( - Icons.share, - ), - onTap: () { - Navigator.of(context).pop(); - - Share.share( - "https://www.pixiv.net/artworks/${widget.id}"); - }, - ), - ListTile( - leading: Icon( - Icons.link, - ), - title: Text(I18n.of(context).link), - onTap: () async { - await Clipboard.setData(ClipboardData( - text: - "https://www.pixiv.net/artworks/${widget.id}")); - BotToast.showText( - text: I18n.of(context).copied_to_clipboard); - Navigator.of(context).pop(); - }, - ), - ListTile( - title: Text(I18n.of(context).ban), - leading: Icon(Icons.brightness_auto), - onTap: () { - muteStore.insertBanIllusts(BanIllustIdPersist() - ..illustId = widget.id.toString() - ..name = illusts.title); - Navigator.pop(context); - }, - ), - ListTile( - title: Text(I18n.of(context).report), - leading: Icon(Icons.report), - onTap: () async { - await showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text(I18n.of(context).report), - content: - Text(I18n.of(context).report_message), - actions: [ - FlatButton( - child: Text(I18n.of(context).cancel), - onPressed: () { - Navigator.of(context).pop("CANCEL"); - }, - ), - FlatButton( - child: Text(I18n.of(context).ok), - onPressed: () { - Navigator.of(context).pop("OK"); - }, - ), - ], - ); - }); - }, - ) - ], - ), - Container( - height: MediaQuery.of(context).padding.bottom, - ) - ], - ), - ), - ); - }); - } - - @override - Widget build(BuildContext context) { - return Observer(builder: (_) { - for (var i in muteStore.banillusts) { - if (i.illustId == widget.id.toString()) { - return BanPage( - name: I18n.of(context).illust, - ); - } - } - if (_illustStore.illusts != null) { - for (var j in muteStore.banUserIds) { - if (j.userId == _illustStore.illusts.user.id.toString()) { - return BanPage( - name: I18n.of(context).painter, - ); - } - } - for (var t in muteStore.banTags) { - for (var t1 in _illustStore.illusts.tags) { - if (t.name == t1.name) - return BanPage( - name: I18n.of(context).tag, - ); - } - } - } - if (_illustStore.illusts != null) { - final data = _illustStore.illusts; - return Scaffold( - extendBodyBehindAppBar: true, - extendBody: true, - floatingActionButton: GestureDetector( - onLongPress: () { - _showBookMarkTag(); - }, - child: FloatingActionButton( - heroTag: widget.id, - backgroundColor: Colors.white, - onPressed: () => _illustStore.star(), - child: Observer(builder: (context) { - return StarIcon( - state: _illustStore.state, - ); - }), - ), - ), - body: Stack( - children: [ - _buildBody(context, data), - Column( - children: [ - Container( - height: MediaQuery.of(context).padding.top, - ), - Container( - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - IconButton( - icon: Icon(Icons.arrow_back), - onPressed: () { - Navigator.of(context).pop(); - }), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: Icon(Icons.expand_less), - onPressed: () { - itemScrollController.scrollTo( - index: - _illustStore.illusts.pageCount + 1, - duration: Duration(seconds: 1), - curve: Curves.easeInOutCubic); - }), - IconButton( - icon: Icon(Icons.more_vert), - onPressed: () { - buildShowModalBottomSheet( - context, _illustStore.illusts); - }) - ], - ) - ], - ), - ), - ], - ) - ], - )); - } else { - if (_illustStore.errorMessage != null) { - return Scaffold( - appBar: AppBar(), - body: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text(':(', - style: Theme.of(context).textTheme.headline4), - ), - Text('${_illustStore.errorMessage}'), - RaisedButton( - onPressed: () { - _illustStore.fetch(); - }, - child: Text(I18n.of(context).refresh), - ) - ], - ), - ), - ); - } - return Scaffold( - appBar: AppBar(), - body: Container( - child: Center( - child: CircularProgressIndicator(), - ), - ), - ); - } - }); - } - - List buildPage(BuildContext context, Illusts data) { - if (data.pageCount == 1) { - return [_inkWellPic(context, data, 0)]; - } else { - List result = []; - for (var i = 0; i < data.metaPages.length; i++) { - result.add(_inkWellPic(context, data, i)); - } - return result; - } - } - - Widget _buildBody(BuildContext context, Illusts data) { - return ScrollablePositionedList.builder( - itemCount: data.pageCount + 4, - padding: EdgeInsets.all(0.0), - itemScrollController: itemScrollController, - itemPositionsListener: itemPositionsListener, - itemBuilder: (BuildContext context, int index) { - if (index == 0) { - if (!userSetting.isBangs) return Container(); - return Container(height: MediaQuery.of(context).padding.top); - } - if (index <= data.pageCount) { - if (data.type != "ugoira") - return _inkWellPic(context, data, index); - else - return UgoiraLoader( - id: widget.id, - illusts: data, - ); - } - if (index == data.pageCount + 1) { - return IllustDetailBody( - illust: data, - ); - } - if (index == data.pageCount + 2) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Text(I18n.of(context).about_picture), - ); - } - if (index == data.pageCount + 3) { - return IllustAboutGrid( - id: widget.id, - ); - } - return Container(); - }, - ); - } - - Widget _inkWellPic(BuildContext context, Illusts data, int index) { - return InkWell( - child: buildPictures(context, data, index), - onLongPress: () { - final illust = data; - showModalBottomSheet( - context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(16), - ), - ), - builder: (c1) { - return Container( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - illust.metaPages.isNotEmpty - ? ListTile( - title: Text(I18n.of(context).muti_choice_save), - leading: Icon( - Icons.save, - ), - onTap: () async { - Navigator.of(context).pop(); - _showMutiChoiceDialog(illust, context); - }, - ) - : Container(), - ListTile( - leading: Icon(Icons.save_alt), - onTap: () async { - Navigator.of(context).pop(); - saveStore.saveImage(illust, index: index - 1); - }, - title: Text(I18n.of(context).save), - ), - ListTile( - leading: Icon(Icons.cancel), - onTap: () => Navigator.of(context).pop(), - title: Text(I18n.of(context).cancel), - ), - Container( - height: MediaQuery.of(c1).padding.bottom, - ) - ], - ), - ); - }); - }, - onTap: () { - Navigator.of(context) - .push(MaterialPageRoute(builder: (BuildContext context) { - return PhotoViewerPage( - index: index - 1, - illusts: data, - ); - })); - }, - ); - } - - Future _showMutiChoiceDialog(Illusts illust, BuildContext context) async { - List indexs = List(illust.metaPages.length); - bool allOn = false; - for (int i = 0; i < illust.metaPages.length; i++) { - indexs[i] = false; - } - final result = await showDialog( - context: context, - child: StatefulBuilder(builder: (context, setDialogState) { - return AlertDialog( - title: Text(I18n.of(context).muti_choice_save), - actions: [ - FlatButton( - child: Text(I18n.of(context).cancel), - onPressed: () { - Navigator.pop(context); - }, - ), - FlatButton( - onPressed: () { - Navigator.pop(context, "OK"); - }, - child: Text(I18n.of(context).ok), - ), - ], - content: Container( - width: double.maxFinite, - child: ListView.builder( - shrinkWrap: true, - itemBuilder: (context, index) => index == 0 - ? ListTile( - title: Text(I18n.of(context).all), - trailing: Checkbox( - value: allOn, - onChanged: (ischeck) { - setDialogState(() { - allOn = ischeck; - if (ischeck) - for (int i = 0; i < indexs.length; i++) { - indexs[i] = true; - } //这真不是我要这么写的,谁知道这个格式化缩进这么奇怪 - else { - for (int i = 0; i < indexs.length; i++) { - indexs[i] = false; - } - } - }); - }), - ) - : ListTile( - title: Text((index - 1).toString()), - trailing: Checkbox( - value: indexs[index - 1], - onChanged: (ischeck) { - setDialogState(() { - indexs[index - 1] = ischeck; - }); - }), - ), - itemCount: illust.metaPages.length + 1, - ), - ), - ); - }), - ); - switch (result) { - case "OK": - { - saveStore.saveChoiceImage(illust, indexs); - } - } - } - - Widget buildPictures(BuildContext context, Illusts data, int index) { - if (data.pageCount == 1 && userSetting.pictureQuality == 1) { - return Hero( - child: PixivImage( - data.imageUrls.large, - fade: false, - placeWidget: PixivImage( - data.imageUrls.medium, - placeWidget: Container( - height: 150, - child: Center(child: CircularProgressIndicator()), - ), - fade: false, - ), - ), - tag: '${data.imageUrls.medium}${widget.heroString}', - ); - } - return (data.pageCount == 1) - ? Hero( - child: PixivImage( - data.imageUrls.medium, - fade: false, - placeWidget: Container( - height: 150, - child: Center(child: CircularProgressIndicator()), - ), - ), - tag: '${data.imageUrls.medium}${widget.heroString}', - ) - : _buildIllustsItem(index - 1, data); - } - - Widget _buildIllustsItem(int index, Illusts illust) { - return index == 0 - ? (userSetting.pictureQuality == 1 - ? Hero( - child: PixivImage( - illust.metaPages[index].imageUrls.large, - placeWidget: PixivImage( - illust.metaPages[index].imageUrls.medium, - fade: false, - ), - fade: false, - ), - tag: '${illust.imageUrls.medium}${widget.heroString}', - ) - : Hero( - child: PixivImage( - illust.metaPages[index].imageUrls.medium, - fade: false, - placeWidget: PixivImage( - illust.metaPages[index].imageUrls.medium, - fade: false, - ), - ), - tag: '${illust.imageUrls.medium}${widget.heroString}', - )) - : PixivImage( - userSetting.pictureQuality == 0 - ? illust.metaPages[index].imageUrls.medium - : illust.metaPages[index].imageUrls.large, - fade: false, - enableMemoryCache: false, - placeWidget: Container( - height: 150, - child: Center( - child: Text('$index', - style: Theme.of(context).textTheme.headline4), - ), - ), - ); - } -} diff --git a/lib/page/picture/ugoira_loader.dart b/lib/page/picture/ugoira_loader.dart index 1d19e6e24..de42829b7 100644 --- a/lib/page/picture/ugoira_loader.dart +++ b/lib/page/picture/ugoira_loader.dart @@ -23,8 +23,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:image/image.dart'; import 'package:image/image.dart' hide Color; -import 'package:path/path.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:pixez/component/pixiv_image.dart'; import 'package:pixez/component/ugoira_painter.dart'; import 'package:pixez/generated/l10n.dart'; @@ -158,28 +156,6 @@ class _UgoiraLoaderState extends State { ); }); } - - Future _isolateWay() async { - Map map = Map(); - map[1] = _store.ugoiraMetadataResponse; - map[2] = _store.drawPool; - final illusts = widget.illusts; - List result = await compute(encodeGif, map); - File cacheFile = File( - join((await getTemporaryDirectory()).path, 'cache_gif', - "${illusts.id}.gif"), - ); - if (!cacheFile.existsSync()) { - cacheFile.createSync(recursive: true); - } - cacheFile.writeAsBytesSync(result); - String fileName = userSetting.singleFolder - ? "${illusts.user.name}_${illusts.user.id}/${illusts.id}" - : "${illusts.id}"; - await saveStore.saveToGallery( - cacheFile.readAsBytesSync(), illusts, fileName); - BotToast.showText(text: "encoding succes"); - } } Future> encodeGif(Map a) async { diff --git a/lib/page/user/user_page.dart b/lib/page/user/user_page.dart deleted file mode 100644 index 218281cc3..000000000 --- a/lib/page/user/user_page.dart +++ /dev/null @@ -1,145 +0,0 @@ -import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; -import 'package:flutter/material.dart' hide NestedScrollView; -import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:pixez/generated/l10n.dart'; -import 'package:pixez/main.dart'; -import 'package:pixez/models/illust.dart'; -import 'package:pixez/page/shield/shield_page.dart'; -import 'package:pixez/page/user/bookmark/bookmark_page.dart'; -import 'package:pixez/page/user/detail/user_detail.dart'; -import 'package:pixez/page/user/user_store.dart'; -import 'package:pixez/page/user/works/works_page.dart'; - -class UserPage extends StatefulWidget { - final int id; - final User user; - - const UserPage({Key key, @required this.id, this.user}) : super(key: key); - - @override - _UserPageState createState() => _UserPageState(); -} - -class _UserPageState extends State - with SingleTickerProviderStateMixin { - UserStore userStore; - TabController _tabController; - ScrollController _scrollController; - int _tabIndex = 0; - - @override - void initState() { - userStore = UserStore(widget.id, user: widget.user); - _tabController = TabController(length: 3, vsync: this); - _scrollController = ScrollController(); - super.initState(); - } - - @override - void dispose() { - _scrollController?.dispose(); - _tabController?.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Observer(builder: (_) { - if (muteStore.banUserIds.isNotEmpty) { - if (muteStore.banUserIds - .map((element) => int.parse(element.userId)) - .contains(widget.id)) { - return Scaffold( - appBar: AppBar( - backgroundColor: Colors.transparent, - elevation: 0.0, - ), - extendBodyBehindAppBar: true, - extendBody: true, - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('X_X'), - RaisedButton( - child: Text(I18n.of(context).shielding_settings), - onPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) => ShieldPage())); - }, - ) - ], - ), - ), - ); - } - } - - if (userStore.errorMessage != null) { - if (userStore.errorMessage == '404') - return Scaffold( - appBar: AppBar(), - body: Container( - child: Center( - child: Text('404 not found'), - )), - ); - return Scaffold( - appBar: AppBar(), - body: Container( - child: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text('Http error'), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: RaisedButton( - color: Theme.of(context).accentColor, - onPressed: () { - userStore.errorMessage = null; - userStore.firstFetch(); - }, - child: Text(I18n.of(context).refresh), - ), - ) - ], - ), - )), - ); - } - return Scaffold( - body: NestedScrollView( - pinnedHeaderSliverHeightBuilder: () { - return MediaQuery.of(context).padding.top + kToolbarHeight + 46.0; - }, - controller: _scrollController, - innerScrollPositionKeyBuilder: () { - var index = "Tab"; - index += _tabController.index.toString(); - return Key(index); - }, - body: IndexedStack(index: _tabIndex, children: [ - NestedScrollViewInnerScrollPositionKeyWidget( - Key('Tab0'), - WorksPage( - id: widget.id, - )), - NestedScrollViewInnerScrollPositionKeyWidget( - Key('Tab1'), - BookmarkPage( - isNested: true, - id: widget.id, - )), - NestedScrollViewInnerScrollPositionKeyWidget( - Key('Tab2'), UserDetailPage(userDetail: userStore.userDetail)), - ]), - )); - }); - } -} diff --git a/lib/page/webview/webview_spotlight_page.dart b/lib/page/webview/webview_spotlight_page.dart deleted file mode 100644 index e8cd17567..000000000 --- a/lib/page/webview/webview_spotlight_page.dart +++ /dev/null @@ -1,189 +0,0 @@ -// /* -// * Copyright (C) 2020. by perol_notsf, All rights reserved -// * -// * This program is free software: you can redistribute it and/or modify it under -// * the terms of the GNU General Public License as published by the Free Software -// * Foundation, either version 3 of the License, or (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, but WITHOUT ANY -// * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License along with -// * this program. If not, see . -// */ - -// import 'dart:io'; -// import 'dart:typed_data'; - -// import 'package:dio/dio.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -// import 'package:pixez/main.dart'; -// import 'package:pixez/models/spotlight_response.dart'; -// import 'package:pixez/network/api_client.dart'; -// import 'package:pixez/page/picture/illust_page.dart'; -// import 'package:pixez/page/user/users_page.dart'; - -// class WebViewSpotlightPage extends StatefulWidget { -// final String url; -// final SpotlightArticle spotlight; - -// const WebViewSpotlightPage({Key key, @required this.url, this.spotlight}) -// : super(key: key); - -// @override -// _WebViewSpotlightPageState createState() => _WebViewSpotlightPageState(); -// } - -// class _WebViewSpotlightPageState extends State { -// @override -// void initState() { -// super.initState(); -// } - -// Future _navigate(String url) async { -// if (url.startsWith("https://www.pixiv.net")) { -// var segments = Uri.parse(url).pathSegments; -// var target = segments[1]; -// if (target == 'artworks') { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (_) => IllustPage( -// id: int.parse(segments.last), -// ))); -// } -// if (target == 'users') { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (_) => UsersPage( -// id: int.parse(segments.last), -// ))); -// } -// } -// debugPrint(url); -// } - -// @override -// void dispose() { -// super.dispose(); -// } - -// InAppWebViewController controller; - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// appBar: AppBar(), -// extendBodyBehindAppBar: true, -// extendBody: true, -// body: InAppWebView( - -// initialUrl: widget.url, -// initialHeaders: { -// HttpHeaders.acceptLanguageHeader: ApiClient.Accept_Language, -// HttpHeaders.userAgentHeader: -// 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/85.0.4183.15', -// }, -// initialOptions: InAppWebViewGroupOptions( -// crossPlatform: InAppWebViewOptions( -// debuggingEnabled: true, -// useShouldOverrideUrlLoading: true, -// useShouldInterceptFetchRequest: true, - -// ), -// ios: IOSInAppWebViewOptions( -// sharedCookiesEnabled: false -// ), -// android: AndroidInAppWebViewOptions( -// thirdPartyCookiesEnabled:false, -// useShouldInterceptRequest: !userSetting.disableBypassSni)), -// onLoadStart: (InAppWebViewController controller, String url) {}, -// onLoadStop: (InAppWebViewController controller, String url) async {}, -// onLoadError: (InAppWebViewController controller, String url, int code, -// String message) { -// debugPrint(message); -// }, -// shouldInterceptFetchRequest: (controller, request) { -// String url = request.url; -// if (url.contains('d.pixiv.org') || -// url.contains('platform.twitter.com') || -// url.contains('connect.facebook.net') || -// url.contains('www.google-analytics.com')) { -// return Future(() { -// return FetchRequest(url: 'http://127.0.0.1'); //直接撞墙出错,减少无用js加载时间 -// }); -// } -// return Future(() { -// return request; -// }); -// }, -// shouldOverrideUrlLoading: (InAppWebViewController controller, -// ShouldOverrideUrlLoadingRequest -// shouldOverrideUrlLoadingRequest) async { -// debugPrint(shouldOverrideUrlLoadingRequest.url); -// if (Platform.isAndroid || -// shouldOverrideUrlLoadingRequest.iosWKNavigationType == -// IOSWKNavigationType.LINK_ACTIVATED) { -// var url = shouldOverrideUrlLoadingRequest.url; -// if (url.startsWith("https://www.pixiv.net")) { -// var segments = Uri.parse(url).pathSegments; -// var target = segments[segments.length - 2]; -// if (target == 'artworks') { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (_) => IllustPage( -// id: int.parse(segments.last), -// ))); -// } -// if (target == 'users') { -// Navigator.of(context).push(MaterialPageRoute( -// builder: (_) => UsersPage( -// id: int.parse(segments.last), -// ))); -// } -// } -// return ShouldOverrideUrlLoadingAction.CANCEL; -// } -// if (!shouldOverrideUrlLoadingRequest.url.startsWith("https") || -// shouldOverrideUrlLoadingRequest.url.contains('weibo.com')) { -// return ShouldOverrideUrlLoadingAction.CANCEL; -// } -// return ShouldOverrideUrlLoadingAction.ALLOW; -// }, -// androidShouldInterceptRequest: (InAppWebViewController controller, -// WebResourceRequest request) async { -// String url = request.url; -// if (url.contains('d.pixiv.org') || -// url.contains('platform.twitter.com') || -// url.contains('connect.facebook.net') || -// url.contains('pixon.ads-pixiv.net')|| -// url.contains('www.google-analytics.com')) { -// return WebResourceResponse( -// contentType: "application/javascript", data: Uint8List(0)); -// } -// Response> response = await Dio().get(request.url, -// options: Options( -// headers: request.headers, responseType: ResponseType.bytes)); -// return WebResourceResponse(data: response.data); -// }, -// onProgressChanged: -// (InAppWebViewController controller, int progress) async { -// if (progress >= 100) { -// try { -// var data = await controller.evaluateJavascript(source: """ -// var a=document.getElementsByClassName('fbbsp__inner')[0]; -// var b=document.getElementsByClassName('gnvsp__inner')[0]; -// var c=document.getElementsByTagName('section')[0]; -// var d=document.getElementsByClassName('amsp__related-articles')[0]; -// a.parentElement.removeChild(a); -// b.parentElement.removeChild(b); -// c.parentElement.removeChild(c); -// d.parentElement.removeChild(d); -// var h =document.getElementsByTagName('header')[0]; -// h.parentElement.removeChild(h); -// """); -// } catch (e) {} -// } -// }, -// ), -// ); -// } -// } diff --git a/pubspec.lock b/pubspec.lock index edc6dd551..20505fbde 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -252,7 +252,7 @@ packages: name: extended_nested_scroll_view url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.0.1" extended_text: dependency: "direct main" description: @@ -525,13 +525,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.5.1" - like_button: - dependency: "direct main" - description: - name: like_button - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.4" logging: dependency: transitive description: @@ -546,13 +539,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.12.10-nullsafety.1" - md2_tab_indicator: - dependency: "direct main" - description: - name: md2_tab_indicator - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.2" meta: dependency: transitive description: @@ -720,7 +706,7 @@ packages: name: provider url: "https://pub.flutter-io.cn" source: hosted - version: "4.3.2+3" + version: "4.3.3" pub_semver: dependency: transitive description: @@ -741,7 +727,7 @@ packages: name: pull_to_refresh url: "https://pub.flutter-io.cn" source: hosted - version: "1.6.3" + version: "1.6.4" quick_actions: dependency: "direct main" description: @@ -762,7 +748,7 @@ packages: name: receive_sharing_intent url: "https://pub.flutter-io.cn" source: hosted - version: "1.4.2" + version: "1.4.3" save_in_gallery: dependency: "direct main" description: @@ -770,13 +756,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.1.3" - scrollable_positioned_list: - dependency: "direct main" - description: - name: scrollable_positioned_list - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.1.9" share: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 2284d0b46..68ae9078f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,16 +39,14 @@ dependencies: flutter_mobx: ^1.1.0+2 flutter_inapp_purchase: ^3.0.1 flutter_widget_from_html_core: ^0.5.1+4 - extended_nested_scroll_view: ^2.0.0 - scrollable_positioned_list: ^0.1.9 + extended_nested_scroll_view: ^2.0.1 flutter_date_pickers: ^0.1.8 device_info: ^1.0.0 - provider: ^4.3.2+2 + provider: ^4.3.3 flutter_displaymode: ^0.1.1 - receive_sharing_intent: ^1.4.2 - like_button: ^1.0.4 + receive_sharing_intent: ^1.4.3 flutter_hooks: ^0.15.0 - pull_to_refresh: ^1.6.3 + pull_to_refresh: ^1.6.4 extended_image: ^1.5.0 flutter_colorpicker: ^0.3.4 waterfall_flow: ^2.0.5 @@ -64,7 +62,6 @@ dependencies: image_picker: ^0.6.7+21 intl: ^0.16.1 intl_utils: ^1.9.0 - md2_tab_indicator: ^1.0.2 quiver: ^2.1.5 flutter_swiper: ^1.1.6 image: ^2.1.19