Skip to content

Commit

Permalink
🔖 releasing v1.0.0-RC2.
Browse files Browse the repository at this point in the history
  • Loading branch information
iota9star committed May 30, 2021
1 parent 3342527 commit 74bc312
Show file tree
Hide file tree
Showing 24 changed files with 144 additions and 100 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ full API reference.

| :heart: | :fire: | :sparkles: | :ok_hand: |
| -----| ---- | ---- | ---- |
| ![](static/screenshot/Screenshot_20210529-133203.jpg) | ![](static/screenshot/Screenshot_20210529-133232.jpg) | ![](static/screenshot/Screenshot_20210529-133246.jpg) | ![](static/screenshot/Screenshot_20210529-133306.jpg) |
| ![](static/screenshot/Screenshot_20210529-133328.jpg) | ![](static/screenshot/Screenshot_20210529-133336.jpg) | ![](static/screenshot/Screenshot_20210529-133349.jpg) | ![](static/screenshot/Screenshot_20210529-133409.jpg) |
| ![](static/screenshot/Screenshot_20210529-140004.jpg) | ![](static/screenshot/Screenshot_20210529-140019.jpg) | ![](static/screenshot/Screenshot_20210529-140052.jpg) | ![](static/screenshot/Screenshot_20210529-141624.jpg) |
| ![](static/screenshot/Screenshot_20210529-141657.jpg) | ![](static/screenshot/Screenshot_20210529-142739.jpg) | ![](static/screenshot/Screenshot_20210529-142758.jpg) | ![](static/screenshot/Screenshot_20210529-142810.jpg) |
| ![](static/screenshot/Screenshot_20210529-142825.jpg) | ![](static/screenshot/Screenshot_20210529-142835.jpg) | ![](static/screenshot/Screenshot_20210529-142851.jpg) | ![](static/screenshot/Screenshot_20210529-142912.jpg) |
| ![](static/screenshot/Screenshot_20210529-142918.jpg) | ![](static/screenshot/Screenshot_20210529-142925.jpg) | ![](static/screenshot/Screenshot_20210529-142929.jpg) | ![](static/screenshot/Screenshot_20210529-143110.jpg) |
| ![](static/screenshot/Screenshot_20210529-143116.jpg) | ![](static/screenshot/Screenshot_20210529-143127.jpg) | ![](static/screenshot/Screenshot_20210529-143215.jpg) | ![](static/screenshot/Screenshot_20210529-143302.jpg) |
| ![](static/screenshot/Screenshot_20210529-143317.jpg) | ![](static/screenshot/Screenshot_20210529-143328.jpg) | ![](static/screenshot/Screenshot_20210529-143342.jpg) |
| ![](static/screenshot/img.png) | ![](static/screenshot/img1.png) | ![](static/screenshot/img2.png) | ![](static/screenshot/img3.png) |
| ![](static/screenshot/img_1.png) | ![](static/screenshot/img_2.png) | ![](static/screenshot/img_3.png) | ![](static/screenshot/img_4.png) |
| ![](static/screenshot/img_5.png) | ![](static/screenshot/img_6.png) | ![](static/screenshot/Screenshot_20210529-133203.jpg) | ![](static/screenshot/Screenshot_20210529-133232.jpg) |
| ![](static/screenshot/Screenshot_20210529-133246.jpg) | ![](static/screenshot/Screenshot_20210529-133306.jpg) | ![](static/screenshot/Screenshot_20210529-133328.jpg) | ![](static/screenshot/Screenshot_20210529-133336.jpg) |
| ![](static/screenshot/Screenshot_20210529-133349.jpg) | ![](static/screenshot/Screenshot_20210529-133409.jpg) | ![](static/screenshot/Screenshot_20210529-140004.jpg) | ![](static/screenshot/Screenshot_20210529-140019.jpg) |
| ![](static/screenshot/Screenshot_20210529-140052.jpg) | ![](static/screenshot/Screenshot_20210529-141624.jpg) | ![](static/screenshot/Screenshot_20210529-141657.jpg) | ![](static/screenshot/Screenshot_20210529-142739.jpg) |
| ![](static/screenshot/Screenshot_20210529-142758.jpg) | ![](static/screenshot/Screenshot_20210529-142810.jpg) | ![](static/screenshot/Screenshot_20210529-142825.jpg) | ![](static/screenshot/Screenshot_20210529-142835.jpg) |
| ![](static/screenshot/Screenshot_20210529-142851.jpg) | ![](static/screenshot/Screenshot_20210529-142912.jpg) | ![](static/screenshot/Screenshot_20210529-142918.jpg) | ![](static/screenshot/Screenshot_20210529-142925.jpg) |
| ![](static/screenshot/Screenshot_20210529-142929.jpg) | ![](static/screenshot/Screenshot_20210529-143110.jpg) | ![](static/screenshot/Screenshot_20210529-143116.jpg) | ![](static/screenshot/Screenshot_20210529-143127.jpg) |
| ![](static/screenshot/Screenshot_20210529-143215.jpg) | ![](static/screenshot/Screenshot_20210529-143302.jpg) | ![](static/screenshot/Screenshot_20210529-143317.jpg) | ![](static/screenshot/Screenshot_20210529-143328.jpg) |
| ![](static/screenshot/Screenshot_20210529-143342.jpg) |

## Dependencies

Expand Down
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:mikan_flutter/providers/firebase_model.dart';
import 'package:mikan_flutter/providers/home_model.dart';
import 'package:mikan_flutter/providers/index_model.dart';
import 'package:mikan_flutter/providers/list_model.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/providers/theme_model.dart';
import 'package:oktoast/oktoast.dart';
Expand Down Expand Up @@ -92,6 +93,9 @@ class MikanApp extends StatelessWidget {
ChangeNotifierProvider<SubscribedModel>(
create: (_) => SubscribedModel(),
),
ChangeNotifierProvider<OpModel>(
create: (_) => OpModel(),
),
ChangeNotifierProvider<IndexModel>(
create: (context) => IndexModel(context.read<SubscribedModel>()),
),
Expand Down
51 changes: 51 additions & 0 deletions lib/providers/op_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:mikan_flutter/internal/extension.dart';
import 'package:mikan_flutter/internal/http.dart';
import 'package:mikan_flutter/internal/repo.dart';
import 'package:mikan_flutter/providers/base_model.dart';

class OpModel extends CancelableBaseModel {
subscribeBangumi(
final String bangumiId,
final bool subscribed, {
final String? subgroupId,
final VoidCallback? onSuccess,
final ValueChanged<String?>? onError,
}) async {
if (bangumiId.isNullOrBlank) {
return "番组id为空,忽略当前订阅".toast();
}
final int? bid = int.tryParse(bangumiId);
if (bid == null) {
return "番组id为空,忽略当前订阅".toast();
}
int? sid;
if (subgroupId.isNotBlank) {
sid = int.tryParse(subgroupId!);
if (sid == null) {
return "字幕组id解析错误,忽略当前订阅".toast();
}
}
final Resp resp = await (this +
Repo.subscribeBangumi(
bid,
subscribed,
subgroupId: sid,
));
if (resp.success) {
onSuccess?.call();
} else {
onError?.call(resp.msg);
}
}

String _flag = "";

String get flag => _flag;

subscribeChanged(String flag) {
this._flag = flag;
notifyListeners();
}
}
4 changes: 4 additions & 0 deletions lib/providers/record_detail_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ class RecordDetailModel extends CancelableBaseModel {
}
notifyListeners();
}

subscribeChanged() {
notifyListeners();
}
}
35 changes: 0 additions & 35 deletions lib/providers/subscribed_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "package:collection/collection.dart";
import 'package:flutter/foundation.dart';
import 'package:mikan_flutter/internal/extension.dart';
import 'package:mikan_flutter/internal/http.dart';
import 'package:mikan_flutter/internal/repo.dart';
Expand Down Expand Up @@ -93,38 +92,4 @@ class SubscribedModel extends CancelableBaseModel {
}
notifyListeners();
}

subscribeBangumi(
final String bangumiId,
final bool subscribed, {
final String? subgroupId,
final VoidCallback? onSuccess,
final ValueChanged<String?>? onError,
}) async {
if (bangumiId.isNullOrBlank) {
return "番组id为空,忽略当前订阅".toast();
}
final int? bid = int.tryParse(bangumiId);
if (bid == null) {
return "番组id为空,忽略当前订阅".toast();
}
int? sid;
if (subgroupId.isNotBlank) {
sid = int.tryParse(subgroupId!);
if (sid == null) {
return "字幕组id解析错误,忽略当前订阅".toast();
}
}
final Resp resp = await (this +
Repo.subscribeBangumi(
bid,
subscribed,
subgroupId: sid,
));
if (resp.success) {
onSuccess?.call();
} else {
onError?.call(resp.msg);
}
}
}
74 changes: 41 additions & 33 deletions lib/ui/fragments/bangumi_sliver_grid_fragment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import 'package:mikan_flutter/internal/delegate.dart';
import 'package:mikan_flutter/internal/extension.dart';
import 'package:mikan_flutter/mikan_flutter_routes.dart';
import 'package:mikan_flutter/model/bangumi.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:mikan_flutter/widget/tap_scale_container.dart';
import 'package:provider/provider.dart';

typedef HandleSubscribe = void Function(Bangumi bangumi, String flag);

Expand Down Expand Up @@ -196,39 +198,45 @@ class BangumiSliverGridFragment extends StatelessWidget {
}

Widget _buildSubscribeButton(final Bangumi bangumi, final String currFlag) {
return bangumi.subscribed
? SizedBox(
width: 28.0,
height: 28.0,
child: IconButton(
tooltip: "取消订阅",
padding: edge4,
iconSize: 20.0,
icon: Icon(
FluentIcons.heart_24_filled,
color: Colors.redAccent,
),
onPressed: () {
this.handleSubscribe.call(bangumi, currFlag);
},
),
)
: SizedBox(
width: 28.0,
height: 28.0,
child: IconButton(
tooltip: "订阅",
padding: edge4,
iconSize: 20.0,
icon: Icon(
FluentIcons.heart_24_regular,
color: Colors.blueGrey,
),
onPressed: () {
this.handleSubscribe.call(bangumi, currFlag);
},
),
);
return Selector<OpModel, String>(
selector: (_, model) => model.flag,
shouldRebuild: (_, next) => next == currFlag,
builder: (_, __, ___) {
return bangumi.subscribed
? SizedBox(
width: 28.0,
height: 28.0,
child: IconButton(
tooltip: "取消订阅",
padding: edge4,
iconSize: 20.0,
icon: Icon(
FluentIcons.heart_24_filled,
color: Colors.redAccent,
),
onPressed: () {
this.handleSubscribe.call(bangumi, currFlag);
},
),
)
: SizedBox(
width: 28.0,
height: 28.0,
child: IconButton(
tooltip: "订阅",
padding: edge4,
iconSize: 20.0,
icon: Icon(
FluentIcons.heart_24_regular,
color: Colors.blueGrey,
),
onPressed: () {
this.handleSubscribe.call(bangumi, currFlag);
},
),
);
},
);
}

Widget _buildBangumiItemCover(
Expand Down
7 changes: 5 additions & 2 deletions lib/ui/fragments/index_fragment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:mikan_flutter/model/record_item.dart';
import 'package:mikan_flutter/model/season.dart';
import 'package:mikan_flutter/model/user.dart';
import 'package:mikan_flutter/providers/index_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:mikan_flutter/ui/components/ova_record_item.dart';
import 'package:mikan_flutter/ui/fragments/bangumi_sliver_grid_fragment.dart';
Expand Down Expand Up @@ -86,11 +86,14 @@ class IndexFragment extends StatelessWidget {
padding: edgeHB16T4,
bangumis: bangumiRow.bangumis,
handleSubscribe: (bangumi, flag) {
context.read<SubscribedModel>().subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
bangumi.id,
bangumi.subscribed,
onSuccess: () {
bangumi.subscribed = !bangumi.subscribed;
context
.read<OpModel>()
.subscribeChanged(flag);
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/fragments/subscribed_fragment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:mikan_flutter/model/bangumi.dart';
import 'package:mikan_flutter/model/record_item.dart';
import 'package:mikan_flutter/model/season_gallery.dart';
import 'package:mikan_flutter/model/year_season.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:mikan_flutter/ui/components/rss_record_item.dart';
Expand Down Expand Up @@ -179,11 +180,12 @@ class SubscribedFragment extends StatelessWidget {
bangumis: bangumis!,
padding: edgeH16V8,
handleSubscribe: (bangumi, flag) {
context.read<SubscribedModel>().subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
bangumi.id,
bangumi.subscribed,
onSuccess: () {
bangumi.subscribed = !bangumi.subscribed;
context.read<OpModel>().subscribeChanged(flag);
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/pages/record_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import 'package:mikan_flutter/internal/delegate.dart';
import 'package:mikan_flutter/internal/extension.dart';
import 'package:mikan_flutter/internal/screen.dart';
import 'package:mikan_flutter/model/record_details.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/providers/record_detail_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:provider/provider.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
Expand Down Expand Up @@ -529,12 +529,12 @@ class RecordDetailPage extends StatelessWidget {
color: Colors.redAccent,
),
onPressed: () {
context.read<SubscribedModel>().subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
recordDetail.id,
recordDetail.subscribed,
onSuccess: () {
recordDetail.subscribed = !recordDetail.subscribed;
context.read<RecordDetailModel>().notifyListeners();
context.read<RecordDetailModel>().subscribeChanged();
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand All @@ -551,12 +551,12 @@ class RecordDetailPage extends StatelessWidget {
color: Colors.blueGrey,
),
onPressed: () {
context.read<SubscribedModel>().subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
recordDetail.id,
recordDetail.subscribed,
onSuccess: () {
recordDetail.subscribed = !recordDetail.subscribed;
context.read<RecordDetailModel>().notifyListeners();
context.read<RecordDetailModel>().subscribeChanged();
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/pages/season_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:mikan_flutter/internal/screen.dart';
import 'package:mikan_flutter/model/bangumi_row.dart';
import 'package:mikan_flutter/model/season_bangumi_rows.dart';
import 'package:mikan_flutter/model/year_season.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/providers/season_list_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:mikan_flutter/ui/fragments/bangumi_sliver_grid_fragment.dart';
import 'package:mikan_flutter/widget/refresh_indicator.dart';
Expand Down Expand Up @@ -116,11 +116,12 @@ class SeasonListPage extends StatelessWidget {
padding: edge16,
bangumis: bangumiRow.bangumis,
handleSubscribe: (bangumi, flag) {
context.read<SubscribedModel>().subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
bangumi.id,
bangumi.subscribed,
onSuccess: () {
bangumi.subscribed = !bangumi.subscribed;
context.read<OpModel>().subscribeChanged(flag);
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/pages/single_season_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:mikan_flutter/internal/extension.dart';
import 'package:mikan_flutter/internal/screen.dart';
import 'package:mikan_flutter/model/bangumi_row.dart';
import 'package:mikan_flutter/model/season.dart';
import 'package:mikan_flutter/providers/op_model.dart';
import 'package:mikan_flutter/providers/season_model.dart';
import 'package:mikan_flutter/providers/subscribed_model.dart';
import 'package:mikan_flutter/topvars.dart';
import 'package:mikan_flutter/ui/fragments/bangumi_sliver_grid_fragment.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
Expand Down Expand Up @@ -78,13 +78,14 @@ class SingleSeasonPage extends StatelessWidget {
padding: edge16,
bangumis: bangumiRow.bangumis,
handleSubscribe: (bangumi, flag) {
context
.read<SubscribedModel>()
.subscribeBangumi(
context.read<OpModel>().subscribeBangumi(
bangumi.id,
bangumi.subscribed,
onSuccess: () {
bangumi.subscribed = !bangumi.subscribed;
context
.read<OpModel>()
.subscribeChanged(flag);
},
onError: (msg) {
"订阅失败:$msg".toast();
Expand Down
Loading

0 comments on commit 74bc312

Please sign in to comment.