Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Riktam-Santra committed May 11, 2023
1 parent 47e86db commit c3fb608
Show file tree
Hide file tree
Showing 26 changed files with 689 additions and 188 deletions.
24 changes: 22 additions & 2 deletions .metadata
@@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: d79295af24c3ed621c33713ecda14ad196fd9c31
revision: f72efea43c3013323d1b95cff571f3c1caa37583
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
- platform: linux
create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
base_revision: f72efea43c3013323d1b95cff571f3c1caa37583

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
29 changes: 29 additions & 0 deletions analysis_options.yaml
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
1 change: 0 additions & 1 deletion lib/main.dart
Expand Up @@ -6,7 +6,6 @@ import 'package:fludex/services/data_models/settings_data/settings.dart';
import 'package:fludex/services/data_models/user_data/login_data.dart';
import 'package:fludex/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:mangadex_library/models/login/Login.dart';

void main() {
runApp(MainPage());
Expand Down
136 changes: 70 additions & 66 deletions lib/pages/about_manga/aboutManga.dart

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions lib/pages/library/library.dart
Expand Up @@ -56,18 +56,18 @@ class _Library extends State<Library> {

Future<UserDetails> dummyDetails() async {
return UserDetails(
'ok',
Data(
'',
'',
Attributes(
'Anonymous',
'ok',
Data(
'',
'',
Attributes(
'Anonymous',
[],
0,
),
[],
0,
),
[],
),
);
'');
}

Widget build(BuildContext context) {
Expand Down Expand Up @@ -212,7 +212,8 @@ class _Library extends State<Library> {
),
),
);
} else if (followedManga.data!.data.length == 0) {
} else if (followedManga.data!.data!.length ==
0) {
return Container(
child: Center(
child: Text(
Expand Down Expand Up @@ -341,18 +342,19 @@ class _Library extends State<Library> {
i <
allMangaStatus
.data![index]
.attributes
.tags
.attributes!
.tags!
.length;
i++) {
tags.add(allMangaStatus
.data![
index]
.attributes
.tags[i]
.attributes
.name
.en);
.attributes!
.tags![
i]
.attributes!
.name!
.en!);
}
return SearchResultHolder(
gridView:
Expand Down Expand Up @@ -425,7 +427,7 @@ class _Library extends State<Library> {
),
Align(
alignment: Alignment.bottomCenter,
child: (followedManga.data!.total > 10)
child: (followedManga.data!.total! > 10)
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
Expand Down Expand Up @@ -465,7 +467,7 @@ class _Library extends State<Library> {
.data!.total);
if (resultOffset * 10 <
(followedManga
.data!.total ~/
.data!.total! ~/
10)) {
setState(() {
resultOffset++;
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/library/widgets/custom_app_bar.dart
Expand Up @@ -58,7 +58,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
height: 150,
child: Center(
child: Text(
snapshot.data!.data.attributes.username
snapshot.data!.data!.attributes!.username!
.characters.first
.toUpperCase(),
style: TextStyle(
Expand All @@ -73,7 +73,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
height: 10,
),
Text(
snapshot.data!.data.attributes.username,
snapshot.data!.data!.attributes!.username!,
style: TextStyle(fontSize: 17),
)
],
Expand Down
16 changes: 8 additions & 8 deletions lib/pages/login/login_page.dart
Expand Up @@ -124,10 +124,10 @@ class _LoginPageState extends State<LoginPage> {
'ok') {
await FludexUtils()
.saveLoginData(
loginData.token
.session,
loginData.token
.refresh);
loginData.token!
.session!,
loginData.token!
.refresh!);
animation.controller
.reverse()
.whenComplete(() => {
Expand Down Expand Up @@ -252,11 +252,11 @@ class _LoginPageState extends State<LoginPage> {
await FludexUtils()
.saveLoginData(
loginData
.token
.session,
.token!
.session!,
loginData
.token
.refresh);
.token!
.refresh!);
if (loginData
.result ==
'ok') {
Expand Down
46 changes: 23 additions & 23 deletions lib/pages/mangaReader/mangaReader.dart
Expand Up @@ -3,10 +3,10 @@ import 'package:fludex/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:mangadex_library/mangadexServerException.dart';
import 'package:mangadex_library/mangadex_library.dart';
import 'package:mangadex_library/models/aggregate/Aggregate.dart';
import 'package:mangadex_library/models/aggregate/aggregate.dart';
import 'package:mangadex_library/models/common/data.dart';
import 'package:mangadex_library/models/common/language_codes.dart';
import 'package:mangadex_library/models/login/Login.dart';
import 'package:mangadex_library/enums/language_codes.dart';
import 'package:mangadex_library/models/login/login.dart';

class MangaReader extends StatefulWidget {
const MangaReader({
Expand Down Expand Up @@ -75,20 +75,20 @@ class _MangaReaderState extends State<MangaReader> {

var volumes = widget.mangaAggregate.volumes;
var volumeIndex = 0;
volumes.asMap().forEach((key, value) {
volumes!.forEach((key, value) {
if (value.volume == widget.volume) {
volumeIndex = key;
volumeIndex = key as int;
}
});
volumes.forEach((element) {
if (element.volume == widget.volume) {
print('element.volume was: ${element.volume}: ${widget.volume}');
element.chapters.forEach((key, value) {
volumes.forEach((element, volume) {
if (element == widget.volume) {
print('element.volume was: $element: ${widget.volume}');
volume.chapters!.forEach((key, value) {
print('current value of key is : $key');
if (widget.mangaAggregate.volumes[volumeIndex].chapters[key]!.id ==
if (widget.mangaAggregate.volumes![volumeIndex]!.chapters![key]!.id ==
widget.chapterId) {
print(
'$key : ${widget.mangaAggregate.volumes[volumeIndex].chapters[key]!.id}');
'$key : ${widget.mangaAggregate.volumes![volumeIndex]!.chapters![key]!.id}');
requiredChapter = key;
}
});
Expand All @@ -105,8 +105,8 @@ class _MangaReaderState extends State<MangaReader> {
// });

filepaths = FludexUtils().getAllFilePaths(
widget.mangaAggregate.volumes[volumeIndex].chapters["$requiredChapter"]!
.id,
widget.mangaAggregate.volumes![volumeIndex]!
.chapters!["$requiredChapter"]!.id!,
widget.dataSaver);
super.initState();
}
Expand All @@ -117,7 +117,7 @@ class _MangaReaderState extends State<MangaReader> {
print('Chapter number given: ${widget.chapterNumber}');
return Scaffold(
appBar: AppBar(
title: Text(widget.mangaData.attributes.title.en),
title: Text(widget.mangaData.attributes!.title!.en!),
actions: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
Expand Down Expand Up @@ -178,8 +178,8 @@ class _MangaReaderState extends State<MangaReader> {
setState(() {
currentChapter -= 1;
filepaths = FludexUtils().getAllFilePaths(
widget.mangaAggregate.volumes[currentVolume]
.chapters["$currentChapter"]!.id,
widget.mangaAggregate.volumes![currentVolume]!
.chapters!["$currentChapter"]!.id!,
widget.dataSaver);
currentPage = 0;
});
Expand All @@ -195,10 +195,10 @@ class _MangaReaderState extends State<MangaReader> {
if (loginData != null) {
try {
await markChapterReadOrUnRead(
widget.mangaData.id, loginData!.session,
widget.mangaData.id!, loginData!.session!,
chapterIdsRead: [
widget.mangaAggregate.volumes[currentVolume]
.chapters[currentChapter]!.id,
widget.mangaAggregate.volumes![currentVolume]!
.chapters![currentChapter]!.id!,
]);
print('marked chapter as read.');
} catch (e) {
Expand All @@ -217,13 +217,13 @@ class _MangaReaderState extends State<MangaReader> {
}
}
if (currentChapter <
widget.mangaAggregate.volumes[currentVolume]
.chapters.length) {
widget.mangaAggregate.volumes![currentVolume]!
.chapters!.length) {
setState(() {
currentChapter += 1;
filepaths = FludexUtils().getAllFilePaths(
widget.mangaAggregate.volumes[currentVolume]
.chapters["$currentChapter"]!.id,
widget.mangaAggregate.volumes![currentVolume]!
.chapters!["$currentChapter"]!.id!,
widget.dataSaver);
currentPage = 0;
});
Expand Down

0 comments on commit c3fb608

Please sign in to comment.