Skip to content

Commit

Permalink
refactor: make novel search page responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
reyyuuki committed Dec 1, 2024
1 parent 5e51316 commit 1d7add1
Showing 1 changed file with 88 additions and 97 deletions.
185 changes: 88 additions & 97 deletions lib/Screens/Novel/novel_search.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@

// ignore_for_file: must_be_immutable, file_names

import 'dart:developer';
import 'package:daizy_tv/Provider/sources_provider.dart';
import 'package:daizy_tv/components/Anime/_gridlist.dart';
import 'package:daizy_tv/components/Manga/_manga_list.dart';
import 'package:daizy_tv/components/Novel/novel_gridlist.dart';
import 'package:daizy_tv/components/Novel/novel_serachList.dart';
import 'package:daizy_tv/utils/api/Anilist/Manga/manga_search.dart';
import 'package:daizy_tv/utils/sources/Manga/Extenstions/mangakakalot_unofficial.dart';
import 'package:daizy_tv/utils/sources/Novel/Extensions/wuxia_novel.dart';
import 'package:flutter/material.dart';
import 'package:iconsax/iconsax.dart';
import 'package:ionicons/ionicons.dart';
Expand Down Expand Up @@ -46,7 +41,8 @@ class _SearchpageState extends State<NovelSearch> {
Future<void> fetchdata() async {
final provider = Provider.of<SourcesProvider>(context, listen: false);
try {
final response = await provider.novelInstance.scrapeNovelSearchData(widget.name);
final response =
await provider.novelInstance.scrapeNovelSearchData(widget.name);
if (response.toString().isNotEmpty) {
setState(() {
data = response;
Expand All @@ -72,107 +68,102 @@ class _SearchpageState extends State<NovelSearch> {

@override
Widget build(BuildContext context) {
if (data == null) {
return const Center(child: CircularProgressIndicator());
}

return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
body: Column(
children: [
const SizedBox(height: 45),
Row(
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
size: 30,
),
body: Padding(
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 30,),
IconButton(
onPressed: () {
Navigator.pop(context);
},
hoverColor: Colors.transparent,
alignment: Alignment.topLeft,
icon: const Icon(
Icons.arrow_back_ios,
size: 40,
),
SizedBox(
height: 55,
width: 280,
child: TextField(
controller: _controller,
onSubmitted: (value) {
handleSearch(value);
},
decoration: InputDecoration(
prefixIcon: const Icon(Iconsax.search_normal),
labelText: 'Search Novel',
labelStyle: TextStyle(color: Theme.of(context).colorScheme.primary),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
),
const SizedBox(height: 30),
const Text(
"Serach Novel",
style: TextStyle(fontFamily: "Poppins-Bold", fontSize: 30),
),
const SizedBox(
height: 30,
),
Row(
children: [
Expanded(
child: TextField(
controller: _controller,
onSubmitted: (value) {
setState(() {
data = null;
});
handleSearch(value);
},
decoration: InputDecoration(
prefixIcon: const Icon(Iconsax.search_normal),
labelText: "Search Novel",
hintText: 'Search Novel',
labelStyle:
TextStyle(color: Theme.of(context).colorScheme.primary),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary,
width: 1)),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Theme.of(context).colorScheme.inversePrimary,
width: 1)),
fillColor: Theme.of(context).colorScheme.surface,
filled: true,
),
fillColor:
Theme.of(context).colorScheme.surface,
filled: true,
),
),
),
],
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Search Results",
style: TextStyle(
fontSize: 20,
fontFamily: "Poppins-Bold",
const SizedBox(
width: 10,
),
IconButton(
onPressed: () {
setState(() {
isGrid = !isGrid;
});
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.surfaceContainerHigh),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)))),
iconSize: 30,
icon: Icon(isGrid ? Ionicons.grid : Iconsax.menu_15,
color: Theme.of(context).colorScheme.primary),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Row(
children: [
GestureDetector(
onTap: () {
changList(true);
},
child: Icon(
Iconsax.menu_15,
color: isGrid
? Theme.of(context).colorScheme.primary
: Colors.grey,
)),
const SizedBox(
width: 10,
),
GestureDetector(
onTap: () {
changList(false);
},
child: Icon(
Ionicons.grid,
color: !isGrid
? Theme.of(context).colorScheme.primary
: Colors.grey,
)),
],
),
)
],
),
),
Expanded(
child: isGrid ?
NovelGridlist(data: data)
: NovelSerachlist(data: data, ),
),
],
const SizedBox(
height: 10,
),
Expanded(
child: data == null ? const Center(child: CircularProgressIndicator(),) : (isGrid
? NovelGridlist(data: data)
: NovelSerachlist(
data: data,
)),
),
],
),
),
);
}
Expand Down

0 comments on commit 1d7add1

Please sign in to comment.