Skip to content

Commit

Permalink
Favourites, history coming soon
Browse files Browse the repository at this point in the history
  • Loading branch information
femalemonkeyman committed Mar 29, 2023
1 parent 27093c0 commit a3465c8
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 77 deletions.
9 changes: 6 additions & 3 deletions lib/anime/anime_videos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:anicross/providers/anime_providers.dart';
import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';
import 'package:better_player/better_player.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:media_kit/media_kit.dart';
Expand Down Expand Up @@ -40,7 +41,9 @@ class AniViewerState extends State<AniViewer> {
widget.episode['id'],
) ??
widget.episode;
setState(() {});
setState(() {
subtitles = getMedia['subtitles'] ?? [];
});
},
);
}
Expand Down Expand Up @@ -76,7 +79,7 @@ class AniViewerState extends State<AniViewer> {

@override
Widget build(context) {
if (getMedia.isNotEmpty) {
if (getMedia.isNotEmpty && !kIsWeb) {
if (isPhone) {
BetterPlayerDataSource source = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
Expand Down Expand Up @@ -199,7 +202,7 @@ class VideoControlsState extends State<VideoControls> {
Widget build(context) {
return GestureDetector(
onTap: () => setState(() {
(widget.player.state.isPlaying)
(widget.player.state.playing)
? widget.player.pause()
: widget.player.play();
}),
Expand Down
60 changes: 47 additions & 13 deletions lib/info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import 'package:anicross/providers/info_models.dart';
import 'package:anicross/providers/manga_providers.dart';
import 'package:expandable_text/expandable_text.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'widgets/image.dart';

class InfoPage extends StatefulWidget {
final AniData data;

const InfoPage({required this.data, super.key});

@override
Expand All @@ -18,6 +20,10 @@ class InfoPage extends StatefulWidget {

class InfoPageState extends State<InfoPage> {
List content = [];
final Isar isar = Isar.getInstance() ??
Isar.openSync(
[AniDataSchema],
);

@override
void initState() {
Expand All @@ -34,16 +40,30 @@ class InfoPageState extends State<InfoPage> {
super.initState();
}

@override
void dispose() {
super.dispose();
}

@override
Widget build(context) {
final expands = Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Divider(),
ExpandableText(
widget.data.description,
expandText: "More",
collapseText: "Less",
maxLines: 8,
),
const Divider(
height: 15,
),
Wrap(
spacing: 10,
runSpacing: 10,
spacing: 7,
runSpacing: 5,
children: List.generate(
widget.data.tags.length.clamp(0, 20),
(index) {
Expand All @@ -55,15 +75,6 @@ class InfoPageState extends State<InfoPage> {
},
),
),
const Divider(
height: 15,
),
ExpandableText(
widget.data.description,
expandText: "More",
collapseText: "Less",
maxLines: 8,
),
],
);
return Scaffold(
Expand Down Expand Up @@ -111,8 +122,31 @@ class InfoPageState extends State<InfoPage> {
height: 20,
),
ActionChip(
onPressed: () {},
avatar: const Icon(MdiIcons.bookmark),
onPressed: () => setState(
() {
QueryBuilder<AniData, AniData,
QAfterFilterCondition> media =
isar.aniDatas.filter().mediaIdMatches(
widget.data.mediaId,
);

if (media.isEmptySync()) {
isar.writeTxnSync(
() => isar.aniDatas.putSync(widget.data),
);
} else {
isar.writeTxnSync(
() => media.deleteAllSync(),
);
}
},
),
avatar: (isar.aniDatas
.filter()
.mediaIdMatches(widget.data.mediaId)
.isEmptySync())
? const Icon(MdiIcons.bookmarkOutline)
: const Icon(MdiIcons.bookmark),
label: const Text("Later"),
),
if (MediaQuery.of(context).size.width /
Expand Down
57 changes: 57 additions & 0 deletions lib/later_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:anicross/providers/info_models.dart';
import 'package:anicross/widgets/grid.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';

class LaterPage extends StatefulWidget {
const LaterPage({super.key});

@override
State createState() => LaterPageState();
}

class LaterPageState extends State<LaterPage> {
List<AniData> animeData = [];
List<AniData> mangaData = [];
final Isar isar = Isar.getInstance() ??
Isar.openSync(
[AniDataSchema],
);
late final dataChange = isar.aniDatas.watchLazy(fireImmediately: true);

@override
void initState() {
super.initState();
}

void updateData() {
animeData = isar.aniDatas.filter().typeEqualTo("anime").findAllSync();
mangaData = isar.aniDatas.filter().typeEqualTo("manga").findAllSync();
}

@override
Widget build(context) {
return StreamBuilder(
stream: dataChange,
builder: (context, snap) {
updateData();
return CustomScrollView(
slivers: [
Grid(
data: animeData,
paginate: () {},
keep: false,
length: animeData.length,
),
Grid(
data: mangaData,
paginate: () {},
keep: false,
length: mangaData.length,
),
],
);
},
);
}
}
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:anicross/color_schemes.g.dart';
import 'package:anicross/later_page.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
Expand Down Expand Up @@ -58,8 +59,7 @@ class AniNav extends StatelessWidget {
MangaPage(),
//NovelPage(),
Placeholder(),
Placeholder(),
//SizedBox.shrink(),
LaterPage(),
],
),
),
Expand Down
70 changes: 45 additions & 25 deletions lib/manga/manga_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ class MangaControls extends StatefulWidget {
}

class MangaControlsState extends State<MangaControls> {
bool show = true;
bool show = false;

@override
void dispose() {
widget.controller.dispose();
super.dispose();
}

@override
Widget build(context) {
Expand All @@ -100,6 +106,10 @@ class MangaControlsState extends State<MangaControls> {
opacity: !show ? 0.0 : 1.0,
child: Stack(
children: [
Positioned(
child: Text(
widget.controller.page.toString(),
)),
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
Expand All @@ -117,30 +127,40 @@ class MangaControlsState extends State<MangaControls> {
),
),
),
Positioned.fill(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
widget.controller.jumpToPage(
(widget.controller.page! + 1).toInt(),
);
},
),
),
Flexible(
child: GestureDetector(
onTap: () {
widget.controller.jumpToPage(
(widget.controller.page! - 1).toInt(),
);
},
),
),
],
Positioned(
top: 0,
left: 0,
width: MediaQuery.of(context).size.width / 2,
child: GestureDetector(
onTap: () {
widget.controller.jumpToPage(
(widget.controller.page! + 1).toInt(),
);
},
),
),
Positioned(
top: 0,
right: 0,
width: MediaQuery.of(context).size.width / 2,
child: GestureDetector(
onTap: () {
widget.controller.jumpToPage(
(widget.controller.page! - 1).toInt(),
);
},
),
),
Positioned(
height: MediaQuery.of(context).size.height / 5,
left: 0,
right: 0,
bottom: 0,
child: GestureDetector(
//behavior: HitTestBehavior.opaque,
onTap: () => setState(
() => (show) ? show = false : show = true,
),
),
),
const BackButton(),
Expand Down
17 changes: 8 additions & 9 deletions lib/providers/anime_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ Future<Map?> mediaInfo(id) async {

//Begin Hanime
Future<List?> haniList(String name) async {
//name.split(pattern).getRange(0, 3);
Response json = await Dio().post(
"https://search.htv-services.com/",
data: jsonEncode(
{
"search_text": (name.split(" ").length > 3)
? name.split(" ").getRange(0, 3).join(" ").replaceAll(":", "")
: name,
// "${name.split(" ")[0]} ${name.split(" ")[1]} ${name.split(" ")[2]}"
// .replaceAll(":", ""),
? name.split(" ").getRange(0, 3).join(" ")
: name.replaceAll("☆", " "),
"tags": [],
"tags-mode": "AND",
"brands": [],
Expand All @@ -58,14 +55,16 @@ Future<List?> haniList(String name) async {
);
if (json.data['nbHits'] > 0) {
final List results = jsonDecode(json.data['hits']);

List videos = [];

for (var i in results) {
for (Map i in results) {
Response v = await Dio().get(
"https://hanime.tv/api/v8/video?id=${i['id']}",
);
videos.add(v.data);
print(i['name'].toString().similarityTo(name));
if (i['name'].toString().similarityTo(name) > 0.2) {
print("yes");
videos.add(v.data);
}
}

return List.generate(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Block extends StatelessWidget {
position: DecorationPosition.foreground,
decoration: BoxDecoration(
border: Border.all(strokeAlign: -0.050),
borderRadius: BorderRadius.circular(30),
borderRadius: BorderRadius.circular(15),
gradient: const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
Expand Down
Loading

0 comments on commit a3465c8

Please sign in to comment.