Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
femalemonkeyman committed Mar 23, 2023
1 parent 7e5447a commit f5e8340
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 366 deletions.
56 changes: 29 additions & 27 deletions lib/anime/anime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,35 @@ class AniPageState extends State<AniPage> with AutomaticKeepAliveClientMixin {
builder: (context, setState) => AlertDialog(
content: SizedBox(
width: MediaQuery.of(context).size.width / 2,
child: Wrap(
spacing: 20,
runSpacing: 20,
children: List.generate(
genresList.length,
(index) {
return FilterChip(
labelPadding: const EdgeInsets.all(15),
padding: const EdgeInsets.all(2),
selected: selectedGenres.contains(
genresList[index],
),
label: Text(
genresList[index],
),
onSelected: (value) async {
if (value) {
selectedGenres.add(genresList[index]);
} else {
selectedGenres.remove(genresList[index]);
}
setState(
() {},
);
},
);
},
child: SingleChildScrollView(
child: Wrap(
spacing: 20,
runSpacing: 20,
children: List.generate(
genresList.length,
(index) {
return FilterChip(
labelPadding: const EdgeInsets.all(15),
padding: const EdgeInsets.all(2),
selected: selectedGenres.contains(
genresList[index],
),
label: Text(
genresList[index],
),
onSelected: (value) async {
if (value) {
selectedGenres.add(genresList[index]);
} else {
selectedGenres.remove(genresList[index]);
}
setState(
() {},
);
},
);
},
),
),
),
),
Expand Down
55 changes: 34 additions & 21 deletions lib/anime/anime_videos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,38 @@ class AniViewerState extends State<AniViewer> {
super.initState();
}

Future desktopPlayer() async {
controller = await VideoController.create(player!.handle);
Future desktopPlayer(String url) async {
player = Player(
configuration: const PlayerConfiguration(),
);
controller = await VideoController.create(
player!.handle,
);
Directory dir = await getTemporaryDirectory();
String path = "";
for (final i in subtitles) {
await Dio().download(i['url'], "${dir.path}/${i['lang']}subs.vtt");
if (i['lang'] == "English") {
path = "${dir.path}/${i['lang']}subs.vtt";
}
(player!.platform as libmpvPlayer).setProperty("sub-files", path);
}
await (player!.platform as libmpvPlayer).setProperty("sub-files", path);
await player!.open(
Playlist(
[
Media(
url,
),
],
),
);
}

@override
Widget build(context) {
return FutureBuilder<Map>(
future: getMediaInfo,
builder: (context, snap) {
print(snap.error);
if (snap.hasData && snap.connectionState == ConnectionState.done) {
subtitles = snap.data!['subtitles']!;
if (isPhone) {
Expand All @@ -82,7 +95,10 @@ class AniViewerState extends State<AniViewer> {
);
phonePlayer = BetterPlayerController(
const BetterPlayerConfiguration(
controlsConfiguration: BetterPlayerControlsConfiguration(),
useRootNavigator: true,
controlsConfiguration: BetterPlayerControlsConfiguration(
playerTheme: BetterPlayerTheme.material,
),
deviceOrientationsOnFullScreen: [
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
Expand All @@ -99,26 +115,23 @@ class AniViewerState extends State<AniViewer> {
controller: phonePlayer!,
);
} else {
player = Player(configuration: const PlayerConfiguration());
return FutureBuilder(
future: desktopPlayer(),
future: desktopPlayer(
snap.data!['sources']!.last['url'],
),
builder: (context, innerSnap) {
player!.open(
Playlist(
[
Media(
snap.data!['sources']!.last['url'],
if (innerSnap.connectionState == ConnectionState.done) {
return Stack(
children: [
Video(controller: controller),
VideoControls(
player: player!,
),
],
),
);
return Stack(
children: [
Video(controller: controller),
VideoControls(
player: player!,
),
],
);
}
return const Center(
child: CircularProgressIndicator(),
);
},
);
Expand Down
213 changes: 213 additions & 0 deletions lib/info_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import 'package:anicross/anime/anime_videos.dart';
import 'package:anicross/manga/manga_reader.dart';
import 'package:anicross/providers/anime_providers.dart';
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: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
State createState() => InfoPageState();
}

class InfoPageState extends State<InfoPage> {
List content = [];

@override
void initState() {
Future.microtask(
() async {
content = (widget.data.type == "anime")
? await mediaList(widget.data.mediaId)
: await dexReader(widget.data.mediaId);
setState(() {});
},
);
super.initState();
}

@override
Widget build(context) {
final expands = Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Divider(),
Wrap(
spacing: 10,
runSpacing: 10,
children: List.generate(
widget.data.tags.length.clamp(0, 20),
(index) {
return Chip(
label: Text(
widget.data.tags[index],
),
);
},
),
),
const Divider(
height: 15,
),
ExpandableText(
widget.data.description,
expandText: "More",
collapseText: "Less",
maxLines: 8,
),
],
);
return Scaffold(
body: SafeArea(
child: CustomScrollView(
slivers: [
const SliverPadding(
padding: EdgeInsets.only(left: 15, top: 15),
sliver: SliverToBoxAdapter(
child: Align(
alignment: Alignment.topLeft,
child: BackButton(),
),
),
),
SliverPadding(
padding: const EdgeInsets.all(15),
sliver: SliverToBoxAdapter(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
flex: 2,
fit: FlexFit.tight,
child: AniImage(
image: widget.data.image,
),
),
const VerticalDivider(
width: 20,
),
Flexible(
flex: 4,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.data.title,
style: const TextStyle(
fontSize: 20,
),
),
const Divider(
height: 20,
),
ActionChip(
onPressed: () {},
avatar: const Icon(MdiIcons.bookmark),
label: const Text("Later"),
),
if (MediaQuery.of(context).size.width /
MediaQuery.of(context).size.height >
1.5)
expands,
],
),
),
],
),
),
),
if (MediaQuery.of(context).size.width /
MediaQuery.of(context).size.height <
1.5)
SliverPadding(
padding: const EdgeInsets.only(
left: 15,
right: 15,
),
sliver: SliverToBoxAdapter(
child: expands,
),
),
(content.isNotEmpty)
? SliverPadding(
padding: const EdgeInsets.all(15),
sliver: SliverGrid(
gridDelegate:
const SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 5,
crossAxisSpacing: 6,
maxCrossAxisExtent: 400,
mainAxisExtent: 100,
//childAspectRatio: 4 / 1,
),
delegate: SliverChildBuilderDelegate(
childCount: content.length,
(context, index) {
return GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Scaffold(
body: (widget.data.type == "anime")
? AniViewer(
episodes: content,
episode: content[index],
)
: MangaReader(
chapter: content[index],
chapters: content,
),
);
},
),
),
child: IntrinsicHeight(
child: Card(
elevation: 3,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
content[index]['title'],
overflow: TextOverflow.visible,
),
),
Flexible(
child: Text(
content[index]['number'],
),
),
],
),
),
),
),
);
},
),
),
)
: const SliverToBoxAdapter(
child: Center(
child: CircularProgressIndicator(),
),
),
],
),
),
);
}
}
Loading

0 comments on commit f5e8340

Please sign in to comment.