Skip to content

Commit

Permalink
anime collect done
Browse files Browse the repository at this point in the history
  • Loading branch information
Predidit committed Mar 17, 2024
1 parent 141ec77 commit d67ac0c
Show file tree
Hide file tree
Showing 19 changed files with 437 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- [x] 视频播放器
- [x] 硬件加速
- [x] 在线更新
- [ ] 追番列表
- [x] 追番列表
- [ ] 番剧下载
- [ ] 番剧更新提醒
- [ ] 还有更多 (/・ω・\)
Expand Down
182 changes: 108 additions & 74 deletions lib/bean/anime/anime_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class AnimeInfoCard extends StatefulWidget {
Key? key,
required this.info,
required this.index,
required this.type,
}) : super(key: key);

final AnimeInfo info;
final int index;
final String type;
@override
_AnimeInfoCardState createState() => _AnimeInfoCardState();
}
Expand All @@ -44,98 +46,130 @@ class _AnimeInfoCardState extends State<AnimeInfoCard> {
child: InkWell(
onTap: () async {
SmartDialog.showLoading(msg: '获取中');
debugPrint('AnimeButton被按下 对应链接为 https://anime1.me/?cat=${widget.info.link}');
await popularController.getVideoLink('https://anime1.me/?cat=${widget.info.link}');
debugPrint(
'AnimeButton被按下 对应链接为 https://anime1.me/?cat=${widget.info.link}');
if (widget.info.progress != 1) {
await popularController.getVideoLink(
'https://anime1.me/?cat=${widget.info.link}',
episode: widget.info.progress ?? 1);
} else {
await popularController
.getVideoLink('https://anime1.me/?cat=${widget.info.link}');
}
debugPrint('链接解析成功 ${videoController.videoUrl}');
await popularController.getPageTitle(widget.info.name ?? '');
SmartDialog.dismiss();
if (widget.info.progress != 1) {
SmartDialog.showToast('上次观看到第 ${widget.info.progress} 话');
}
videoController.from = '/tab/' + widget.type + '/';
navigationBarState = Platform.isWindows
? Provider.of<SideNavigationBarState>(context, listen: false)
: Provider.of<NavigationBarState>(context, listen: false);
navigationBarState.hideNavigate();
Modular.to.navigate('/tab/video/');
},
child: Container(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
width: Platform.isWindows ? 800 : 200,
child: Text(
widget.info.name ?? '',
maxLines: 2,
softWrap: true,
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
color: Colors.black),
),
),
SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(8.0),
),
SizedBox(
width: Platform.isWindows ? 800 : 200,
child: Text(
widget.info.episode ?? "77",
style: TextStyle(color: Colors.white),
widget.info.name ?? '',
maxLines: 2,
softWrap: true,
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
color: Colors.black),
),
),
SizedBox(width: 8.0),
Container(
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
(widget.info.year ?? "2077") + (widget.info.season ?? ""),
style: TextStyle(color: Colors.white),
),
),
SizedBox(width: 8.0),
widget.info.subtitle != ''
? Container(
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8.0),
SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
widget.info.episode ?? "77",
style: TextStyle(color: Colors.white),
),
),
child: Text(
widget.info.subtitle ?? "",
style: TextStyle(color: Colors.white),
SizedBox(width: 8.0),
Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
(widget.info.year ?? "2077") +
(widget.info.season ?? ""),
style: TextStyle(color: Colors.white),
),
),
)
: Container(),
SizedBox(width: 8.0),
widget.type == 'popular'
? widget.info.subtitle != ''
? Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
widget.info.subtitle ?? "",
style: TextStyle(color: Colors.white),
),
)
: Container()
: Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8.0),
),
child: Text(
"已追 ${widget.info.progress ?? 1} 话",
style: TextStyle(color: Colors.white),
),
),
],
),
IconButton(
icon: (follow)
? Icon(Icons.favorite, color: Colors.orange)
: Icon(Icons.favorite_border, color: Colors.orange),
onPressed: () {
if (popularController.isLoadingMore == false) {
popularController.updateFollow(
widget.info.link ?? 19951, !(follow));
setState(() {
follow = !follow;
});
SmartDialog.showToast(
follow ? '自己追的番要好好看完哦' : '取消追番成功');
}
},
splashColor: Colors.orange.withOpacity(0.5),
),
],
),
],
),
IconButton(
icon: (follow)
? Icon(Icons.favorite, color: Colors.orange)
: Icon(Icons.favorite_border, color: Colors.orange),
onPressed: () {
popularController.updateFollow(widget.info.link ?? 19951, !(follow));
setState(() {
follow = !follow;
});
SmartDialog.showToast(follow ? '自己追的番要好好看完哦' : '取消追番成功');
},
splashColor: Colors.orange.withOpacity(0.5),
),
],
),
],
),
),

),
),
);
}
Expand Down
15 changes: 9 additions & 6 deletions lib/bean/anime/anime_info.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import 'package:html/dom.dart';
import 'package:oneanime/request/api.dart';
import 'package:oneanime/utils/constans.dart';
import 'package:hive/hive.dart';

import 'anime_basic.dart';

/// This class parses a Node and stores anime info like anime name, anime link, total episodes, year, season and subtitle group
@HiveType(typeId: 0)
class AnimeInfo extends HiveObject {
Expand All @@ -22,6 +17,8 @@ class AnimeInfo extends HiveObject {
String? subtitle;
@HiveField(6)
bool? follow;
@HiveField(7)
int? progress;

AnimeInfo({
this.link,
Expand All @@ -31,6 +28,7 @@ class AnimeInfo extends HiveObject {
this.season,
this.subtitle,
this.follow,
this.progress,
});


Expand Down Expand Up @@ -65,6 +63,7 @@ class AnimeInfo extends HiveObject {
this.season = list[4];
this.subtitle = list[5];
this.follow = false;
this.progress = 1;
}

Map<String, dynamic> toJson() => {
Expand All @@ -73,7 +72,9 @@ class AnimeInfo extends HiveObject {
'year': year,
'episode': episode,
'name': name,
'link': link
'link': link,
'follow': follow,
'progress': progress
};

@override
Expand All @@ -96,6 +97,7 @@ class AnimeInfoAdapter extends TypeAdapter<AnimeInfo> {
season: reader.readString(),
subtitle: reader.readString(),
follow: reader.readBool(),
progress: reader.readInt(),
);
}

Expand All @@ -108,6 +110,7 @@ class AnimeInfoAdapter extends TypeAdapter<AnimeInfo> {
writer.writeString(obj.season ?? '');
writer.writeString(obj.subtitle ?? '');
writer.writeBool(obj.follow ?? false);
writer.writeInt(obj.progress ?? 1);
}
}

1 change: 0 additions & 1 deletion lib/bean/anime/anime_schedule.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:oneanime/request/api.dart';
import 'package:oneanime/bean/anime/anime_basic.dart';
import 'package:html/dom.dart';
import 'package:oneanime/utils/constans.dart';
Expand Down
54 changes: 54 additions & 0 deletions lib/pages/follow/follow_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
import 'package:oneanime/bean/anime/anime_info.dart';
import 'package:oneanime/request/list.dart';
import 'package:oneanime/request/video.dart';
import 'package:oneanime/pages/video/video_controller.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:hive/hive.dart';
import 'package:oneanime/utils/storage.dart';
import 'package:oneanime/pages/popular/popular_controller.dart';
import 'package:flutter_open_chinese_convert/flutter_open_chinese_convert.dart';

part 'follow_controller.g.dart';

class FollowController = _FollowController with _$FollowController;

abstract class _FollowController with Store {
final PopularController popularController = Modular.get<PopularController>();
late List<AnimeInfo> list;
// List<AnimeInfo> list = GStorage.listCahce.values.toList();

@observable
ObservableList<AnimeInfo> followList = ObservableList<AnimeInfo>.of([]);

double scrollOffset = 0.0;
bool isLoadingMore = true;
String keyword = '';

Future getFollowList() async {
followList.clear();
list = popularController.list;
list.asMap().forEach((index, item) {
if(item.follow == true) {
followList.add(item);
}
});
}

Future updateFollow(int link, bool status) async {
list.asMap().forEach((index, item) {
if(item.link == link) {
list[index].follow = status;
return;
}
});
updateData();
}

Future updateData() async {
await GStorage.listCahce.clear();
await GStorage.listCahce.addAll(list);
}
}
34 changes: 34 additions & 0 deletions lib/pages/follow/follow_controller.g.dart

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

Loading

0 comments on commit d67ac0c

Please sign in to comment.