Skip to content

Commit 898fc28

Browse files
committed
like button,0.0.11
1 parent 4df1c2b commit 898fc28

30 files changed

+385
-171
lines changed

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ android {
6363
applicationId "com.perol.pixez"
6464
minSdkVersion 21
6565
targetSdkVersion 29
66-
versionCode 11
67-
versionName "0.0.10 Slider"
66+
versionCode 12
67+
versionName "0.0.11 Store"
6868
}
6969
compileOptions {
7070
sourceCompatibility JavaVersion.VERSION_1_8

lib/component/illust_card.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class _IllustCardState extends State<IllustCard> {
7373
.push(MaterialPageRoute(builder: (_) {
7474
if (widget.store != null) {
7575
return PictureListPage(
76-
iStores: widget.iStores,
77-
store: widget.store,
76+
iStores: widget.iStores,
77+
store: widget.store,
7878
);
7979
}
8080
return IllustPage(
@@ -123,27 +123,18 @@ class _IllustCardState extends State<IllustCard> {
123123
});
124124
}
125125

126+
String heroString =
127+
DateTime.now().millisecondsSinceEpoch.toString(); //两个作品可能出现在相邻页,用时间保证唯一herotag
126128
Widget buildInkWell(BuildContext context) {
127-
double screanWidth = MediaQuery.of(context).size.width;
128-
double itemWidth = (screanWidth / 2.0) - 32.0;
129-
double radio =
130-
illustStore.illusts.height.toDouble() / illustStore.illusts.width.toDouble();
131-
double mainAxisExtent = 80.0;
132-
if (radio > 2)
133-
mainAxisExtent += itemWidth;
134-
else
135-
mainAxisExtent += itemWidth * radio;
136-
137-
String heroString = DateTime.now().millisecondsSinceEpoch.toString();
138129
return InkWell(
139130
onTap: () => {
140131
Navigator.of(context, rootNavigator: true)
141132
.push(MaterialPageRoute(builder: (_) {
142133
if (widget.iStores != null) {
143134
return PictureListPage(
144135
heroString: heroString,
145-
store: widget.store,
146-
iStores: widget.iStores,
136+
store: widget.store,
137+
iStores: widget.iStores,
147138
);
148139
}
149140
return IllustPage(
@@ -171,7 +162,8 @@ class _IllustCardState extends State<IllustCard> {
171162
illustStore.illusts.width.toDouble()) >
172163
2
173164
? Hero(
174-
tag: '${illustStore.illusts.imageUrls.medium}${heroString}',
165+
tag:
166+
'${illustStore.illusts.imageUrls.medium}${heroString}',
175167
child: CachedNetworkImage(
176168
imageUrl: illustStore.illusts.imageUrls.squareMedium,
177169
placeholder: (context, url) => Container(
@@ -186,7 +178,8 @@ class _IllustCardState extends State<IllustCard> {
186178
),
187179
)
188180
: Hero(
189-
tag: '${illustStore.illusts.imageUrls.medium}${heroString}',
181+
tag:
182+
'${illustStore.illusts.imageUrls.medium}${heroString}',
190183
child: CachedNetworkImage(
191184
imageUrl: illustStore.illusts.imageUrls.medium,
192185
placeholder: (context, url) => Container(
@@ -251,7 +244,7 @@ class _IllustCardState extends State<IllustCard> {
251244
);
252245
}
253246

254-
Visibility _buildVisibility() {
247+
Widget _buildVisibility() {
255248
return Visibility(
256249
visible: illustStore.illusts.type != "illust" ||
257250
illustStore.illusts.metaPages.isNotEmpty,

lib/component/star_icon.dart

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
*
1515
*/
1616

17+
import 'package:bot_toast/bot_toast.dart';
1718
import 'package:flutter/material.dart';
1819
import 'package:flutter_mobx/flutter_mobx.dart';
1920
import 'package:like_button/like_button.dart';
21+
import 'package:pixez/generated/l10n.dart';
2022
import 'package:pixez/page/picture/illust_store.dart';
2123

2224
class StarIcon extends StatefulWidget {
@@ -30,25 +32,81 @@ class StarIcon extends StatefulWidget {
3032
_StarIconState createState() => _StarIconState();
3133
}
3234

33-
class _StarIconState extends State<StarIcon>
34-
with SingleTickerProviderStateMixin {
35-
@override
36-
void initState() {
37-
super.initState();
35+
class _StarIconState extends State<StarIcon> {
36+
//造一个Future实现通知并满足返回类型
37+
Future<bool> starWithToast() async {
38+
bool result = await widget.illustStore.star();
39+
if (result != null) {
40+
if (result) {
41+
String toastString =
42+
'${widget.illustStore.illusts.title}${I18n.of(context).Bookmarked}';
43+
BotToast.showCustomText(
44+
onlyOne: true,
45+
duration: Duration(seconds: 1),
46+
toastBuilder: (textCancel) => Align(
47+
alignment: Alignment(0, 0.8),
48+
child: Card(
49+
child: Row(
50+
mainAxisSize: MainAxisSize.min,
51+
children: <Widget>[
52+
Padding(
53+
padding: const EdgeInsets.all(8.0),
54+
child: Icon(
55+
Icons.favorite,
56+
color: Colors.redAccent,
57+
),
58+
),
59+
Padding(
60+
padding: const EdgeInsets.symmetric(
61+
horizontal: 8.0, vertical: 8.0),
62+
child: Text(toastString ?? ''),
63+
)
64+
],
65+
),
66+
),
67+
));
68+
} else {
69+
String toastString =
70+
'${widget.illustStore.illusts.title}${I18n.of(context).Not_Bookmarked}';
71+
BotToast.showCustomText(
72+
onlyOne: true,
73+
duration: Duration(seconds: 1),
74+
toastBuilder: (textCancel) => Align(
75+
alignment: Alignment(0, 0.8),
76+
child: Card(
77+
child: Row(
78+
mainAxisSize: MainAxisSize.min,
79+
children: <Widget>[
80+
Padding(
81+
padding: const EdgeInsets.all(8.0),
82+
child: Icon(
83+
Icons.favorite_border,
84+
),
85+
),
86+
Padding(
87+
padding: const EdgeInsets.symmetric(
88+
horizontal: 8.0, vertical: 8.0),
89+
child: Text(toastString ?? ''),
90+
)
91+
],
92+
),
93+
),
94+
));
95+
}
96+
return result;
97+
} else {}
3898
}
3999

40100
@override
41101
Widget build(BuildContext context) {
42-
return Observer(builder: (_) {
43-
return Container(
44-
width: 32,
45-
child: LikeButton(
46-
size: 26,
102+
return Container(
103+
width: 36,
104+
child: LikeButton(
105+
size: 24,
47106
mainAxisAlignment: MainAxisAlignment.center,
48107
crossAxisAlignment: CrossAxisAlignment.center,
49-
padding: EdgeInsets.all(0.0),
50108
circleColor:
51-
CircleColor(start: Colors.transparent, end: Colors.redAccent),
109+
CircleColor(start: Colors.transparent, end: Colors.red),
52110
bubblesColor: BubblesColor(
53111
dotPrimaryColor: Colors.red,
54112
dotSecondaryColor: Colors.redAccent,
@@ -66,7 +124,6 @@ class _StarIconState extends State<StarIcon>
66124
return widget.illustStore.star();
67125
},
68126
),
69-
);
70-
});
127+
);
71128
}
72129
}

lib/constraint.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Constrains {
2+
static String tagName = "0.0.11";
3+
}

lib/generated/intl/messages_en-US.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MessageLookup extends MessageLookupByLibrary {
3939
"Ban" : MessageLookupByLibrary.simpleMessage("Mute"),
4040
"Block_User" : MessageLookupByLibrary.simpleMessage("Mute this user"),
4141
"BookMark" : MessageLookupByLibrary.simpleMessage("Collections"),
42+
"Bookmarked" : MessageLookupByLibrary.simpleMessage("Bookmarked"),
4243
"Cancel" : MessageLookupByLibrary.simpleMessage("Cancel"),
4344
"Check_For_Updates" : MessageLookupByLibrary.simpleMessage("Check for updates"),
4445
"Choice_you_like" : MessageLookupByLibrary.simpleMessage("Tags will be showing"),
@@ -96,6 +97,7 @@ class MessageLookup extends MessageLookupByLibrary {
9697
"Nickname" : MessageLookupByLibrary.simpleMessage("Nickname"),
9798
"Nickname_can_be_change_anytime" : MessageLookupByLibrary.simpleMessage("Nickname can be changed at any time"),
9899
"No_H" : MessageLookupByLibrary.simpleMessage("H are not allowed!"),
100+
"Not_Bookmarked" : MessageLookupByLibrary.simpleMessage("Not_Bookmarked"),
99101
"OK" : MessageLookupByLibrary.simpleMessage("Confirm"),
100102
"Painter" : MessageLookupByLibrary.simpleMessage("User"),
101103
"Painter_Name" : MessageLookupByLibrary.simpleMessage("User name"),

lib/generated/intl/messages_zh-CN.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MessageLookup extends MessageLookupByLibrary {
3939
"Ban" : MessageLookupByLibrary.simpleMessage("屏蔽"),
4040
"Block_User" : MessageLookupByLibrary.simpleMessage("屏蔽用户"),
4141
"BookMark" : MessageLookupByLibrary.simpleMessage("收藏"),
42+
"Bookmarked" : MessageLookupByLibrary.simpleMessage("已收藏"),
4243
"Cancel" : MessageLookupByLibrary.simpleMessage("取消"),
4344
"Check_For_Updates" : MessageLookupByLibrary.simpleMessage("检查更新"),
4445
"Choice_you_like" : MessageLookupByLibrary.simpleMessage("选择你喜欢的标签"),
@@ -96,6 +97,7 @@ class MessageLookup extends MessageLookupByLibrary {
9697
"Nickname" : MessageLookupByLibrary.simpleMessage("昵称"),
9798
"Nickname_can_be_change_anytime" : MessageLookupByLibrary.simpleMessage("昵称随时可变更"),
9899
"No_H" : MessageLookupByLibrary.simpleMessage("H是不行的!"),
100+
"Not_Bookmarked" : MessageLookupByLibrary.simpleMessage("未收藏"),
99101
"OK" : MessageLookupByLibrary.simpleMessage("确认"),
100102
"Painter" : MessageLookupByLibrary.simpleMessage("画师"),
101103
"Painter_Name" : MessageLookupByLibrary.simpleMessage("画师名"),

lib/generated/intl/messages_zh-TW.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MessageLookup extends MessageLookupByLibrary {
3939
"Ban" : MessageLookupByLibrary.simpleMessage("屏蔽"),
4040
"Block_User" : MessageLookupByLibrary.simpleMessage("屏蔽用戶"),
4141
"BookMark" : MessageLookupByLibrary.simpleMessage("收藏"),
42+
"Bookmarked" : MessageLookupByLibrary.simpleMessage("已收藏"),
4243
"Cancel" : MessageLookupByLibrary.simpleMessage("取消"),
4344
"Check_For_Updates" : MessageLookupByLibrary.simpleMessage("偵測更新"),
4445
"Choice_you_like" : MessageLookupByLibrary.simpleMessage("選擇你喜歡的標簽"),
@@ -96,6 +97,7 @@ class MessageLookup extends MessageLookupByLibrary {
9697
"Nickname" : MessageLookupByLibrary.simpleMessage("暱稱"),
9798
"Nickname_can_be_change_anytime" : MessageLookupByLibrary.simpleMessage("暱稱可隨時變更"),
9899
"No_H" : MessageLookupByLibrary.simpleMessage("H是不行的!"),
100+
"Not_Bookmarked" : MessageLookupByLibrary.simpleMessage("未收藏"),
99101
"OK" : MessageLookupByLibrary.simpleMessage("確定"),
100102
"Painter" : MessageLookupByLibrary.simpleMessage("繪師"),
101103
"Painter_Name" : MessageLookupByLibrary.simpleMessage("繪師名"),

lib/generated/l10n.dart

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/l10n/intl_en_US.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,7 @@
134134
"Encode":"Encode",
135135
"Encode_Message":"This will take time and may fail",
136136
"Filter":"Filter",
137-
"Attempting_To_Log_In":"Attempting to log in"
137+
"Attempting_To_Log_In":"Attempting to log in",
138+
"Bookmarked":"Bookmarked",
139+
"Not_Bookmarked":"Not_Bookmarked"
138140
}

lib/l10n/intl_zh_CN.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,7 @@
134134
"Encode":"合成",
135135
"Encode_Message":"这将会消耗一定时间,并可能会失败",
136136
"Filter":"筛选",
137-
"Attempting_To_Log_In":"尝试登录"
137+
"Attempting_To_Log_In":"尝试登录",
138+
"Bookmarked":"已收藏",
139+
"Not_Bookmarked":"未收藏"
138140
}

lib/l10n/intl_zh_TW.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,7 @@
134134
"Encode":"合成",
135135
"Encode_Message":"這將會消耗壹些時間,並可能會失敗",
136136
"Filter":"篩選",
137-
"Attempting_To_Log_In":"嘗試登入"
137+
"Attempting_To_Log_In":"嘗試登入",
138+
"Bookmarked":"已收藏",
139+
"Not_Bookmarked":"未收藏"
138140
}

lib/lighting/lighting_page.dart

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,38 +91,42 @@ class _LightingListState extends State<LightingList> {
9191
@override
9292
Widget build(BuildContext context) {
9393
return Observer(builder: (_) {
94-
return Stack(
95-
children: <Widget>[
96-
_buildMain(context),
97-
Align(
98-
alignment: Alignment.bottomCenter,
99-
child: Visibility(
100-
visible: backToTopEnable,
101-
child: IconButton(
102-
padding: EdgeInsets.all(0.0),
103-
icon: Icon(Icons.expand_less),
104-
onPressed: () {
105-
_scrollController.jumpTo(0.0);
106-
}),
94+
return Container(
95+
child: Stack(
96+
children: <Widget>[
97+
Padding(
98+
padding: EdgeInsets.only(top: widget.header == null ? 0 : 36.0),
99+
child: _buildWithHeader(context),
107100
),
108-
)
109-
],
101+
Align(
102+
alignment: Alignment.topCenter,
103+
child: Container(
104+
height: 36,
105+
child: widget.header,
106+
) ??
107+
Visibility(
108+
child: Container(),
109+
visible: false,
110+
),
111+
),
112+
Align(
113+
alignment: Alignment.bottomCenter,
114+
child: Visibility(
115+
visible: backToTopEnable,
116+
child: IconButton(
117+
padding: EdgeInsets.all(0.0),
118+
icon: Icon(Icons.expand_less),
119+
onPressed: () {
120+
_scrollController.jumpTo(0.0);
121+
}),
122+
),
123+
)
124+
],
125+
),
110126
);
111127
});
112128
}
113129

114-
Widget _buildMain(BuildContext context) {
115-
if (widget.header == null)
116-
return _buildWithHeader(context);
117-
else
118-
return Column(
119-
children: <Widget>[
120-
widget.header,
121-
Expanded(child: _buildWithHeader(context)),
122-
],
123-
);
124-
}
125-
126130
bool needToBan(Illusts illust) {
127131
for (var i in muteStore.banillusts) {
128132
if (i.illustId == illust.id.toString()) return true;
@@ -179,15 +183,15 @@ class _LightingListState extends State<LightingList> {
179183
itemBuilder: (context, index) {
180184
final data = _store.iStores[index].illusts;
181185
return IllustCard(
182-
store: _store.iStores[index],
186+
store: _store.iStores[index],
183187
iStores: _store.iStores,
184188
);
185189
},
186190
staggeredTileBuilder: (int index) {
187191
double screanWidth = MediaQuery.of(context).size.width;
188192
double itemWidth = (screanWidth / 2.0) - 32.0;
189-
double radio = _store.iStores[index].illusts.height.toDouble() /
190-
_store.iStores[index].illusts.width.toDouble();
193+
double radio = _store.iStores[index].illusts.height.toDouble() /
194+
_store.iStores[index].illusts.width.toDouble();
191195
double mainAxisExtent;
192196
if (radio > 2)
193197
mainAxisExtent = itemWidth;

0 commit comments

Comments
 (0)