Skip to content

Commit

Permalink
sliver
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Aug 17, 2020
1 parent 49c948a commit dbae8bb
Show file tree
Hide file tree
Showing 29 changed files with 310 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ android {
applicationId "com.perol.pixez"
minSdkVersion 21
targetSdkVersion 29
versionCode 22
versionName "0.1.6 ListTile"
versionCode 23
versionName "0.1.7X sliver"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
8 changes: 7 additions & 1 deletion lib/component/illust_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class IllustCard extends HookWidget {
final IllustStore store;
final List<IllustStore> iStores;
final bool needToBan;

final double height;
IllustCard({
@required this.store,
this.iStores,
this.needToBan = false,
this.height,
});

@override
Expand Down Expand Up @@ -92,6 +93,11 @@ class IllustCard extends HookWidget {
);
}
}
if (height != null)
return Container(
child: buildInkWell(context),
height: height,
);
return buildInkWell(context);
}

Expand Down
28 changes: 18 additions & 10 deletions lib/component/painer_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,24 @@ class PainterCard extends StatelessWidget {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0))),
clipBehavior: Clip.antiAlias,
child: CustomScrollView(
slivers: [
SliverGrid.count(
crossAxisCount: 3,
children: user.illusts
.map((e) => PixivImage(e.imageUrls.squareMedium))
.toList(),
),
buildPadding()
],
child: Container(
height: (MediaQuery.of(context).size.width - 4) / 3 + 80,
child: CustomScrollView(
physics: NeverScrollableScrollPhysics(),
slivers: [
SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
delegate: SliverChildBuilderDelegate((context, index) {
if (index >= user.illusts.length) return Container();
return PixivImage(
user.illusts[index].imageUrls.squareMedium,
fit: BoxFit.cover,
);
}, childCount: user.illusts.length)),
SliverToBoxAdapter(child: buildPadding())
],
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/constraint.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Constrains {
static String tagName = "0.1.6";
static String tagName = "0.1.7";
static bool isGooglePlay = false;
}
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en-US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paused" : MessageLookupByLibrary.simpleMessage("Paused"),
"perol_message" : MessageLookupByLibrary.simpleMessage("使用flutter开发"),
"personal" : MessageLookupByLibrary.simpleMessage("Personal"),
"pick_a_color" : MessageLookupByLibrary.simpleMessage("Pick a color"),
"pixel" : MessageLookupByLibrary.simpleMessage("Resolution"),
"please_note_that" : MessageLookupByLibrary.simpleMessage("Please note that"),
"please_note_that_content" : MessageLookupByLibrary.simpleMessage("Only when you make sure that your agent or area can access pixiv, you can turn on this switch. After the switch is turned on, all network problems have nothing to do with the application. Don\'t feed back the problem that you can\'t connect"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_zh-CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paused" : MessageLookupByLibrary.simpleMessage("已暂停"),
"perol_message" : MessageLookupByLibrary.simpleMessage("使用flutter开发"),
"personal" : MessageLookupByLibrary.simpleMessage("个人"),
"pick_a_color" : MessageLookupByLibrary.simpleMessage("选择颜色"),
"pixel" : MessageLookupByLibrary.simpleMessage("分辨率"),
"please_note_that" : MessageLookupByLibrary.simpleMessage("请注意"),
"please_note_that_content" : MessageLookupByLibrary.simpleMessage("只有在确保你的代理或是所处地区能够访问到pixiv时,才能够打开这个开关,开关开启后一切网络问题都与应用无关了,不要反馈无法连接的问题"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_zh-TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paused" : MessageLookupByLibrary.simpleMessage("已暫停"),
"perol_message" : MessageLookupByLibrary.simpleMessage("使用 Flutter 開發"),
"personal" : MessageLookupByLibrary.simpleMessage("個人"),
"pick_a_color" : MessageLookupByLibrary.simpleMessage("選擇顏色"),
"pixel" : MessageLookupByLibrary.simpleMessage("解析度"),
"please_note_that" : MessageLookupByLibrary.simpleMessage("請註意"),
"please_note_that_content" : MessageLookupByLibrary.simpleMessage("只有在確保你的代理或是所處地區能夠訪問 Pixiv 時,才建議啟用此選項,選項開啟後任何網路問題都與本程式無關,請不要回報無法連線的問題"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/l10n/intl_en_US.arb
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@
"warning": "Clear all cache?",
"welcome_page": "Welcome Page",
"which_part": "Index",
"works": "Works"
"works": "Works",
"pick_a_color": "Pick a color"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@
"warning": "清除全部缓存?",
"welcome_page": "欢迎页",
"which_part": "第几张",
"works": "作品"
"works": "作品",
"pick_a_color": "选择颜色"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@
"warning": "清除全部暫存?",
"welcome_page": "預設頁面",
"which_part": "第幾張",
"works": "作品"
"works": "作品",
"pick_a_color": "選擇顏色"
}
87 changes: 40 additions & 47 deletions lib/lighting/lighting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ import 'package:waterfall_flow/waterfall_flow.dart';
class LightingList extends StatefulWidget {
final FutureGet source;
final Widget header;
final ScrollController scrollController;
final bool isNested;

const LightingList(
{Key key,
@required this.source,
this.header,
this.scrollController,
this.isNested})
{Key key, @required this.source, this.header, this.isNested})
: super(key: key);

@override
Expand All @@ -47,38 +41,22 @@ class LightingList extends StatefulWidget {
class _LightingListState extends State<LightingList> {
LightingStore _store;
ScrollController _scrollController;
bool isNested = false;

bool _isNested;
@override
void didUpdateWidget(LightingList oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.source != widget.source) {
_store.source = widget.source;
_store.fetch();
if (!isNested && _store.iStores.isNotEmpty) _scrollController.jumpTo(0.0);
if (!_isNested) _scrollController.jumpTo(0.0);
}
}

@override
void initState() {
isNested = widget.isNested ?? false;
_isNested = widget.isNested ?? false;
if (!_isNested) _scrollController = ScrollController();
_store = LightingStore(widget.source, _refreshController);
_scrollController = widget.scrollController ?? ScrollController();
// _scrollController.addListener(() {
// bool temp;
// if (_scrollController.offset > 400) {
// temp = true;
// } else {
// temp = false;
// }
// if (temp != backToTopEnable) {
// setState(() {
// setState(() {
// this.backToTopEnable = temp;
// });
// });
// }
// });
super.initState();
_store.fetch();
}
Expand All @@ -91,8 +69,6 @@ class _LightingListState extends State<LightingList> {
super.dispose();
}

bool backToTopEnable = false;

@override
Widget build(BuildContext context) {
return Observer(builder: (_) {
Expand All @@ -114,18 +90,6 @@ class _LightingListState extends State<LightingList> {
visible: false,
),
),
Align(
alignment: Alignment.bottomCenter,
child: Visibility(
visible: backToTopEnable,
child: IconButton(
padding: EdgeInsets.all(0.0),
icon: Icon(Icons.expand_less),
onPressed: () {
_scrollController.jumpTo(0.0);
}),
),
)
],
),
);
Expand Down Expand Up @@ -218,9 +182,39 @@ class _LightingListState extends State<LightingList> {
Widget _buildWaterFall() {
double screanWidth = MediaQuery.of(context).size.width;
double itemWidth = (screanWidth / userSetting.crossCount.toDouble()) - 32.0;

if (_isNested) {
return WaterfallFlow.builder(
padding: EdgeInsets.all(5.0),
itemCount: _store.iStores.length,
itemBuilder: (context, index) {
double radio = _store.iStores[index].illusts.height.toDouble() /
_store.iStores[index].illusts.width.toDouble();
double mainAxisExtent;
if (radio > 3)
mainAxisExtent = itemWidth;
else
mainAxisExtent = itemWidth * radio;
return IllustCard(
store: _store.iStores[index],
iStores: _store.iStores,
height: mainAxisExtent + 60.0,
);
},
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: userSetting.crossCount,
collectGarbage: (List<int> garbages) {
garbages.forEach((index) {
final provider = ExtendedNetworkImageProvider(
_store.iStores[index].illusts.imageUrls.medium,
);
provider.evict();
});
},
));
}
return WaterfallFlow.builder(
padding: EdgeInsets.all(5.0),
controller: _scrollController,
itemCount: _store.iStores.length,
itemBuilder: (context, index) {
double radio = _store.iStores[index].illusts.height.toDouble() /
Expand All @@ -230,13 +224,14 @@ class _LightingListState extends State<LightingList> {
mainAxisExtent = itemWidth;
else
mainAxisExtent = itemWidth * radio;
return Container(
child: IllustCard(store: _store.iStores[index]),
return IllustCard(
store: _store.iStores[index],
iStores: _store.iStores,
height: mainAxisExtent + 60.0,
);
},
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisCount: userSetting.crossCount,
collectGarbage: (List<int> garbages) {
garbages.forEach((index) {
final provider = ExtendedNetworkImageProvider(
Expand All @@ -247,6 +242,4 @@ class _LightingListState extends State<LightingList> {
},
));
}


}
14 changes: 7 additions & 7 deletions lib/lighting/lighting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ abstract class _LightingStoreBase with Store {
@observable
ObservableList<IllustStore> iStores = ObservableList();
dispose() {
iStores.forEach((element) {
final provider = ExtendedNetworkImageProvider(
element.illusts.imageUrls.medium,
);
provider.evict();
});
iStores.clear();
// iStores.forEach((element) {
// final provider = ExtendedNetworkImageProvider(
// element.illusts.imageUrls.medium,
// );
// provider.evict();
// });
// iStores.clear();
}

@observable
Expand Down
2 changes: 0 additions & 2 deletions lib/page/hello/android_hello_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
if (Platform.isAndroid) {
try {
Uri initialLink = await getInitialUri();
print(initialLink);
if (initialLink != null) judgePushPage(initialLink);
_sub = getUriLinksStream().listen((Uri link) {
print("link:${link}");
judgePushPage(link);
});
} catch (e) {
Expand Down
26 changes: 14 additions & 12 deletions lib/page/hello/new/new_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@ class _NewPageState extends State<NewPage> {
children: <Widget>[
AppBar(
automaticallyImplyLeading: false,
title:
TabBar(indicatorSize: TabBarIndicatorSize.label, tabs: [
Tab(
text: I18n.of(context).news,
),
Tab(
text: I18n.of(context).bookmark,
),
Tab(
text: I18n.of(context).followed,
),
]),
title: TabBar(
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Theme.of(context).cardColor,
tabs: [
Tab(
text: I18n.of(context).news,
),
Tab(
text: I18n.of(context).bookmark,
),
Tab(
text: I18n.of(context).followed,
),
]),
actions: <Widget>[
IconButton(
icon: Icon(Icons.supervised_user_circle),
Expand Down
8 changes: 6 additions & 2 deletions lib/page/hello/ranking/rank_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class _RankPageState extends State<RankPage> {
children: <Widget>[
AppBar(
title: TabBar(
indicatorSize: TabBarIndicatorSize.label,
isScrollable: true,
indicatorColor: Theme.of(context).cardColor,
tabs: titles
.map((element) => Tab(
text: element,
Expand All @@ -95,8 +97,10 @@ class _RankPageState extends State<RankPage> {
var date = await showDatePicker(
context: context,
initialDate: nowDateTime,
locale: I18n.delegate.supportedLocales[userSetting.languageNum],
firstDate: DateTime(2007,8),//pixiv于2007年9月10日由上谷隆宏等人首次推出第一个测试版...
locale: I18n.delegate
.supportedLocales[userSetting.languageNum],
firstDate: DateTime(
2007, 8), //pixiv于2007年9月10日由上谷隆宏等人首次推出第一个测试版...
lastDate: nowdate);
if (date != null && mounted) {
nowDateTime = date;
Expand Down
Loading

0 comments on commit dbae8bb

Please sign in to comment.