Skip to content

Commit

Permalink
proper code refactor and basic implementations for sauce nao UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Riktam-Santra committed Sep 27, 2022
1 parent 6fe36f4 commit 0c82e1c
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 55 deletions.
Binary file added data/media/SauceNAO_ico.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/media/SauceNao_banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 3 additions & 14 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import 'package:fludex/login/home_page_animator.dart';
import 'package:fludex/utils.dart';
import 'package:fludex/services/controllers/animation_controllers/home_page_anim_controller.dart';
import 'package:fludex/utils/utils.dart';
import 'package:flutter/material.dart';

void main() {
runApp(MainPage());
}

Future<bool> getLightModeSetting() async {
try {
var settings = await FludexUtils().getSettings();
return settings.lightMode;
} on Exception {
await FludexUtils().saveSettings(true, false);
var settings = await FludexUtils().getSettings();
return settings.lightMode;
}
}

class MainPage extends StatelessWidget {
const MainPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return FutureBuilder(
future: getLightModeSetting(),
future: FludexUtils().getLightModeSetting(),
builder: (context, AsyncSnapshot<bool> lightMode) {
return MaterialApp(
debugShowCheckedModeBanner: false,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -884,22 +884,27 @@ class _AboutMangaState extends State<AboutManga> {
'Chapter ' + chapterData.data!.data[index].attributes.chapter,
style: TextStyle(fontSize: 17),
),
subtitle: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Volume ' + chapterData.data!.data[index].attributes.volume,
style: TextStyle(),
subtitle: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Volume ' + chapterData.data!.data[index].attributes.volume,
style: TextStyle(),
),
SizedBox(
width: 10,
),
Text(
'Language: ' + chapterData.data!.data[index].attributes.translatedLanguage,
),
],
),
SizedBox(
width: 10,
),
Text(
'Language: ' + chapterData.data!.data[index].attributes.translatedLanguage,
),
],
),
),
],
),
trailing: PopupMenuButton<int>(
itemBuilder: (context) => [
Expand Down
41 changes: 34 additions & 7 deletions lib/library/library.dart → lib/pages/library/library.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'dart:convert';
import 'dart:io';
import 'package:fludex/utils/utils.dart';
import 'package:fludex/pages/saucenao/saucenao_page.dart';
import 'package:flutter/material.dart';

import 'package:fludex/info/aboutFludex.dart';
import 'package:fludex/search/searchScreen.dart';
import 'package:fludex/settings/settingsPage.dart';
import 'package:fludex/search/searchResultHolder.dart';
import 'package:fludex/utils.dart';
import 'package:fludex/login/home_page_animator.dart';
import 'package:fludex/pages/about/aboutFludex.dart';
import 'package:fludex/pages/search/search_page.dart';
import 'package:fludex/pages/settings/settings_page.dart';
import 'package:fludex/pages/search/widgets/search_result_holder_widget.dart';
import 'package:fludex/services/controllers/animation_controllers/home_page_anim_controller.dart';
import 'package:mangadex_library/mangadexServerException.dart';

import 'package:mangadex_library/mangadex_library.dart' as lib;
Expand All @@ -30,6 +31,7 @@ class _Library extends State<Library> {
int gridCount = 2;
int resultOffset = 0;
bool gridView = false;
bool lightMode = true;
List<String> dropDownMenuItems = [
'All',
'Reading',
Expand Down Expand Up @@ -58,6 +60,7 @@ class _Library extends State<Library> {
}
userDetails = _getLoggedUserDetails(widget.token);
token = widget.token;
FludexUtils().getLightModeSetting().then((value) => {lightMode = value});
}

Future<UserDetails> _getLoggedUserDetails(Token? _token) async {
Expand Down Expand Up @@ -277,6 +280,9 @@ class _Library extends State<Library> {
),
title: Text(
'Library',
style: TextStyle(
fontSize: 16,
),
),
onTap: () {
Navigator.pop(context);
Expand All @@ -289,6 +295,7 @@ class _Library extends State<Library> {
),
title: Text(
'Search Manga',
style: TextStyle(fontSize: 16),
),
onTap: () {
Navigator.pop(context);
Expand All @@ -301,12 +308,31 @@ class _Library extends State<Library> {
);
},
),
ListTile(
leading: SizedBox(
height: 24,
width: 24,
child: Image(
image: AssetImage('data/media/SauceNAO_ico.png'),
color: lightMode ? Colors.grey : Colors.white,
),
),
title: Text('SauceNAO'),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SaucenaoSearch()),
);
},
),
ListTile(
leading: Icon(
Icons.logout,
),
title: Text(
'Logout',
style: TextStyle(fontSize: 16),
),
onTap: () async {
Navigator.pop(context);
Expand All @@ -325,6 +351,7 @@ class _Library extends State<Library> {
),
title: Text(
'About Fludex',
style: TextStyle(fontSize: 16),
),
onTap: () {
Navigator.pop(context);
Expand Down Expand Up @@ -413,7 +440,7 @@ class _Library extends State<Library> {
),
),
style: ElevatedButton.styleFrom(
primary:
backgroundColor:
Color.fromARGB(18, 255, 255, 255)),
)
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:fludex/library/library.dart';
import 'package:fludex/pages/library/library.dart';
import 'package:fludex/utils.dart';
import 'package:flutter/material.dart';
import 'package:mangadex_library/mangadex_library.dart' as lib;
Expand Down
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions lib/pages/saucenao/saucenao_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';

class SaucenaoSearch extends StatefulWidget {
const SaucenaoSearch({Key? key}) : super(key: key);

@override
State<SaucenaoSearch> createState() => _SaucenaoSearchState();
}

class _SaucenaoSearchState extends State<SaucenaoSearch> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(50.0),
child: Image(
image: AssetImage('data/media/SauceNAO_banner.png'),
color: Colors.black,
),
),
),
SizedBox(
height: 500,
width: 500,
child: Card(
child: PageView(
children: [
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: Text(
"Has it ever occured to you that you find a manga page and you don't know from which manga it was?"),
),
Center(
child: Text(
"Well, now you can find them all! It's easy! Just "),
),
],
),
),
],
),
)),
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mangadex_library/models/login/Login.dart';
import 'searchReplyScreen.dart';
import 'widgets/search_reply_widget.dart';

class SearchPage extends StatefulWidget {
final Token? token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mangadex_library/mangadexServerException.dart';
import 'package:mangadex_library/mangadex_library.dart' as lib;
import 'package:mangadex_library/models/login/Login.dart';
import 'package:mangadex_library/models/search/Search.dart';
import 'searchResultHolder.dart';
import 'search_result_holder_widget.dart';

class SearchReplyScreen extends StatefulWidget {
final bool dataSaver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,19 @@ class _SearchResultHolder extends State<SearchResultHolder> {
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter)),
height: 40,
height: 60,
child: Center(
child: Text(
widget.mangaData.attributes.title
.en,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Colors.white),
child: Container(
margin: EdgeInsets.all(5),
child: Text(
widget.mangaData.attributes
.title.en,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Colors.white),
textScaleFactor: 1.15,
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:fludex/saveDataModels/settings.dart';
import 'package:fludex/utils.dart';
import 'package:fludex/services/data_models/settings_data/settings.dart';
import 'package:fludex/utils/utils.dart';
import 'package:flutter/material.dart';

class SettingsPage extends StatefulWidget {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 13 additions & 2 deletions lib/utils.dart → lib/utils/utils.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:convert';
import 'dart:io';
import 'package:fludex/saveDataModels/settings.dart';
import 'package:fludex/services/data_models/settings_data/settings.dart';
import 'package:mangadex_library/models/common/reading_status.dart';
import 'package:mangadex_library/models/login/Login.dart' as l;
import 'package:mangadex_library/mangadex_library.dart';
import 'package:fludex/saveDataModels/loginData.dart';
import 'package:fludex/services/data_models/user_data/login_data.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -38,6 +38,17 @@ class FludexUtils {
return jsonData;
}

Future<bool> getLightModeSetting() async {
try {
var settings = await getSettings();
return settings.lightMode;
} on Exception {
await FludexUtils().saveSettings(true, false);
var settings = await getSettings();
return settings.lightMode;
}
}

void saveLoginData(String session, String refresh) async {
var user = LoginData(session, refresh);
var encodedJson = jsonEncode(user);
Expand Down
4 changes: 0 additions & 4 deletions sampleAppData/sampleData.json

This file was deleted.

0 comments on commit 0c82e1c

Please sign in to comment.