Skip to content

Commit

Permalink
feat: more tv support stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanYuuki committed Feb 5, 2025
1 parent 9041b4c commit e84855e
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 149 deletions.
1 change: 0 additions & 1 deletion lib/screens/anime/details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ class _AnimeDetailsPageState extends State<AnimeDetailsPage> {
return PlatformBuilder(
androidBuilder: _buildAndroidLayout(context),
desktopBuilder: _buildDesktopLayout(context),
strictMode: true,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/anime/watch_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ class _WatchPageState extends State<WatchPage> with TickerProviderStateMixin {
],
),
if (!isLocked.value) ...[_buildPlaybackButtons()],
// if (settings.isTV.value)
if (settings.isTV.value)
Positioned(
right: 10,
top: MediaQuery.of(context).size.height * 0.48,
Expand Down
192 changes: 140 additions & 52 deletions lib/screens/extensions/ExtensionScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:anymex/widgets/AlertDialogBuilder.dart';
import 'package:anymex/widgets/common/glow.dart';
import 'package:anymex/widgets/common/search_bar.dart';
import 'package:anymex/widgets/helper/tv_wrapper.dart';
import 'package:anymex/widgets/minor_widgets/custom_button.dart';
import 'package:anymex/widgets/minor_widgets/custom_text.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -64,6 +65,141 @@ class _BrowseScreenState extends ConsumerState<ExtensionScreen>
final _textEditingController = TextEditingController();
late var _selectedLanguage = 'all';

void repoSheet() {
final controller = Get.find<SourceController>();
final animeRepoController = TextEditingController(
text: controller.activeAnimeRepo,
);
final mangaRepoController = TextEditingController(
text: controller.activeMangaRepo,
);

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Center(
child: AnymexText(
text: "Add Repository",
size: 20,
variant: TextVariant.semiBold,
),
),
const SizedBox(height: 10),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color:
Theme.of(context).colorScheme.surfaceContainerHigh),
padding: const EdgeInsets.all(7),
child: Text(
"WARNING: Adding third-party repositories is not encouraged by the developer. Also make sure to add links for both anime and manga, it won’t work if you add only one.",
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 12,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 20),

// Anime Repository Input
const Padding(
padding: EdgeInsets.only(left: 5, bottom: 5),
child: Text(
"Anime Repository",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
),
),
CustomSearchBar(
prefixIcon: Icons.movie_filter_outlined,
controller: animeRepoController,
onSubmitted: (value) {},
hintText: "Add Anime Repo...",
disableIcons: true,
padding: const EdgeInsets.all(0),
),

const SizedBox(height: 15),

// Manga Repository Input
const Padding(
padding: EdgeInsets.only(left: 5, bottom: 5),
child: Text(
"Manga Repository",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
),
),
CustomSearchBar(
prefixIcon: Iconsax.book,
controller: mangaRepoController,
onSubmitted: (value) {},
hintText: "Add Manga Repo...",
disableIcons: true,
padding: const EdgeInsets.all(0),
),

const SizedBox(height: 20),

// Buttons
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnymeXButton(
height: 50,
width: 200,
borderRadius: BorderRadius.circular(30),
backgroundColor:
Theme.of(context).colorScheme.secondaryContainer,
variant: ButtonVariant.outline,
onTap: () {
Get.back();
},
child: const Text("Cancel"),
),
const SizedBox(width: 10),
AnymeXButton(
height: 50,
width: 200,
borderRadius: BorderRadius.circular(30),
backgroundColor:
Theme.of(context).colorScheme.secondaryContainer,
variant: ButtonVariant.outline,
onTap: () async {
if (animeRepoController.text.isNotEmpty) {
controller.activeAnimeRepo = animeRepoController.text;
}
if (mangaRepoController.text.isNotEmpty) {
controller.activeMangaRepo = mangaRepoController.text;
}

await _fetchData();
await _refreshData();
Get.back();
},
child: const Text("Confirm"),
),
],
),
],
),
),
);
},
);
}

@override
Widget build(BuildContext context) {
_fetchData();
Expand All @@ -87,62 +223,14 @@ class _BrowseScreenState extends ConsumerState<ExtensionScreen>
iconTheme: IconThemeData(color: theme.primary),
actions: [
TVWrapper(
onTap: () {
repoSheet();
},
child: IconButton(
icon:
Icon(HugeIcons.strokeRoundedGithub, color: theme.primary),
onPressed: () {
final controller = Get.find<SourceController>();
final animeRepoController = TextEditingController(
text: controller.activeAnimeRepo,
);
final mangaRepoController = TextEditingController(
text: controller.activeMangaRepo,
);

AlertDialogBuilder(context)
..setTitleWidget(const Center(
child: AnymexText(
text: "Add Repo",
size: 20,
variant: TextVariant.semiBold,
),
))
..setCustomView(
Column(
mainAxisSize: MainAxisSize.min,
children: [
CustomSearchBar(
prefixIcon: HugeIcons.strokeRoundedGithub,
controller: animeRepoController,
onSubmitted: (value) {},
hintText: "Add Anime Repo...",
disableIcons: true,
padding: const EdgeInsets.all(0),
),
const SizedBox(height: 10),
CustomSearchBar(
prefixIcon: HugeIcons.strokeRoundedGithub,
controller: mangaRepoController,
onSubmitted: (value) {},
hintText: "Add Manga Repo...",
disableIcons: true,
padding: const EdgeInsets.all(0),
),
],
),
)
..setPositiveButton("Confirm", () async {
if (animeRepoController.text.isNotEmpty) {
controller.activeAnimeRepo = animeRepoController.text;
}
if (mangaRepoController.text.isNotEmpty) {
controller.activeMangaRepo = mangaRepoController.text;
}

await _fetchData();
await _refreshData();
})
..show();
repoSheet();
},
),
),
Expand Down
101 changes: 47 additions & 54 deletions lib/screens/manga/widgets/search_selector.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:anymex/controllers/service_handler/service_handler.dart';
import 'package:anymex/controllers/settings/methods.dart';
import 'package:anymex/screens/home_page.dart';
import 'package:anymex/screens/search/search_anilist.dart';
import 'package:anymex/utils/fallback/fallback_anime.dart';
import 'package:anymex/utils/fallback/fallback_manga.dart';
import 'package:anymex/widgets/minor_widgets/custom_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
Expand All @@ -10,11 +13,24 @@ void searchTypeSheet(BuildContext context, String searchTerm) {
context: context,
backgroundColor: Theme.of(context).colorScheme.surface,
builder: (context) {
final isDesktop = MediaQuery.of(context).size.width > 600;
final serviceHanlder = Get.find<ServiceHandler>();
final isSimkl = serviceHanlder.serviceType.value == ServicesType.simkl;
final button1Cover = (isSimkl
? serviceHanlder.simklService.trendingMovies
: serviceHanlder.anilistService.trendingAnimes)
.firstWhere((e) => e.cover != null)
.cover ??
'';
final button2Cover = (isSimkl
? serviceHanlder.simklService.trendingSeries
: serviceHanlder.anilistService.trendingMangas)
.firstWhere((e) => e.cover != null)
.cover ??
'';
return Container(
padding: const EdgeInsets.all(10),
width: double.infinity,
height: MediaQuery.of(context).size.height * 0.4,
height: MediaQuery.of(context).size.height * 0.3,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.multiplyRadius()),
),
Expand All @@ -29,65 +45,42 @@ void searchTypeSheet(BuildContext context, String searchTerm) {
const SizedBox(
height: 15,
),
Center(
child: ImageButton(
width: isDesktop
? 300
: MediaQuery.of(context).size.width / 2 - 40,
height: !isDesktop ? 70 : 90,
buttonText: "ANIME",
backgroundImage:
'https://raw.githubusercontent.com/dharmx/walls/main/manga/a_black_and_white_image_of_a_room.jpeg',
borderRadius: 16.multiplyRadius(),
onPressed: () {
Get.back();

Get.to(() => SearchPage(
searchTerm: searchTerm,
isManga: true,
));
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ImageButton(
width: isDesktop
? 300
: MediaQuery.of(context).size.width / 2 - 40,
height: !isDesktop ? 70 : 90,
buttonText: "MANGA",
backgroundImage:
'https://raw.githubusercontent.com/dharmx/walls/main/manga/a_black_and_white_image_of_a_room.jpeg',
borderRadius: 16.multiplyRadius(),
onPressed: () {
Get.back();

Get.to(() => SearchPage(
searchTerm: searchTerm,
isManga: true,
));
},
),
ImageButton(
width: isDesktop
? 300
: MediaQuery.of(context).size.width / 2 - 40,
height: !isDesktop ? 70 : 90,
buttonText: "NOVEL",
backgroundImage:
'https://images8.alphacoders.com/136/1362712.jpeg',
borderRadius: 16.multiplyRadius(),
onPressed: () {
// Get.back();
// Get.to(() => NovelSearchPage(searchTerm: searchTerm));
},
),
_buildSearchTile(context, isSimkl ? "MOVIES" : "ANIME",
button1Cover, false),
_buildSearchTile(context, isSimkl ? "SERIES" : "MANGA",
button2Cover, isSimkl ? false : true),
// _buildSearchTile(
// context,
// 'https://images8.alphacoders.com/136/1362712.jpeg',
// "NOVEL"),
],
),
],
),
);
});
}

ImageButton _buildSearchTile(
BuildContext context, String buttonText, String imageUrl, bool isManga) {
final isDesktop = MediaQuery.of(context).size.width > 600;

return ImageButton(
width: isDesktop ? 300 : MediaQuery.of(context).size.width / 2 - 40,
height: !isDesktop ? 70 : 90,
buttonText: buttonText,
backgroundImage: imageUrl,
borderRadius: 16.multiplyRadius(),
onPressed: () {
Get.back();

Get.to(() => SearchPage(
searchTerm: '',
isManga: isManga,
));
},
);
}
Loading

0 comments on commit e84855e

Please sign in to comment.