mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 23:22:07 +00:00
adjusted mobile layout for tracker library
+ fixed MAL search bug
This commit is contained in:
parent
79da1d2678
commit
2c6e9439e9
4 changed files with 125 additions and 71 deletions
|
|
@ -8,9 +8,11 @@ class ReadMoreWidget extends StatefulWidget {
|
|||
super.key,
|
||||
required this.text,
|
||||
required this.onChanged,
|
||||
this.initExpanded = true,
|
||||
});
|
||||
final Function(bool) onChanged;
|
||||
final String text;
|
||||
final bool initExpanded;
|
||||
|
||||
@override
|
||||
ReadMoreWidgetState createState() => ReadMoreWidgetState();
|
||||
|
|
@ -18,7 +20,7 @@ class ReadMoreWidget extends StatefulWidget {
|
|||
|
||||
class ReadMoreWidgetState extends State<ReadMoreWidget>
|
||||
with TickerProviderStateMixin {
|
||||
late bool expanded = true;
|
||||
late bool expanded = widget.initExpanded;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/l10n/generated/app_localizations.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/models/track_search.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/widgets/readmore.dart';
|
||||
import 'package:mangayomi/modules/widgets/custom_extended_image_provider.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
|
|
@ -22,15 +24,16 @@ class TrackerItemCard extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: _cardContent(context),
|
||||
child: _cardContent(context, l10n),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cardContent(BuildContext context) {
|
||||
Widget _cardContent(BuildContext context, AppLocalizations l10n) {
|
||||
return Stack(
|
||||
children: [
|
||||
Consumer(
|
||||
|
|
@ -89,53 +92,9 @@ class TrackerItemCard extends StatelessWidget {
|
|||
width: context.width(0.8),
|
||||
height: context.height(1),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.width(0.8),
|
||||
child: Row(
|
||||
children: [
|
||||
_coverCard(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
SelectableText(
|
||||
track.summary ?? "",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: SizedBox(
|
||||
width: context.width(0.6),
|
||||
child: context.isTablet
|
||||
? Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
children: _infoRow(context),
|
||||
)
|
||||
: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
spacing: 5,
|
||||
children: _infoRow(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: context.isTablet
|
||||
? _buildContentDesktop(context, l10n)
|
||||
: _buildContentMobile(context, l10n),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -146,8 +105,98 @@ class TrackerItemCard extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
List<Widget> _infoRow(BuildContext context) {
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
Widget _buildContentMobile(BuildContext context, AppLocalizations l10n) {
|
||||
return Column(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.width(0.8),
|
||||
child: Row(
|
||||
children: [
|
||||
_coverCard(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: 6,
|
||||
children: _infoRow(context, l10n),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: SizedBox(
|
||||
width: context.width(0.6),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: 6,
|
||||
children: [
|
||||
ReadMoreWidget(
|
||||
text: track.summary ?? "",
|
||||
initExpanded: false,
|
||||
onChanged: (value) {},
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () => _pushMigrationScreen(context),
|
||||
label: Text(l10n.track_library_add),
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContentDesktop(BuildContext context, AppLocalizations l10n) {
|
||||
return Column(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.width(0.8),
|
||||
child: Row(
|
||||
children: [
|
||||
_coverCard(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [SelectableText(track.summary ?? "")],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: SizedBox(
|
||||
width: context.width(0.6),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () => _pushMigrationScreen(context),
|
||||
label: Text(l10n.track_library_add),
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
..._infoRow(context, l10n),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _infoRow(BuildContext context, AppLocalizations l10n) {
|
||||
return [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
|
|
@ -179,11 +228,6 @@ class TrackerItemCard extends StatelessWidget {
|
|||
label: Text(l10n.open_in_browser),
|
||||
icon: Icon(Icons.public),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () => _pushMigrationScreen(context),
|
||||
label: Text(l10n.track_library_add),
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -215,13 +259,13 @@ class TrackerItemCard extends StatelessWidget {
|
|||
itemType: itemType,
|
||||
source: null,
|
||||
author: "",
|
||||
artist: null,
|
||||
artist: "",
|
||||
genre: [],
|
||||
imageUrl: null,
|
||||
lang: null,
|
||||
link: null,
|
||||
status: Status.unknown,
|
||||
description: null,
|
||||
description: "",
|
||||
),
|
||||
track,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -78,18 +78,8 @@ class _TrackerSectionScreenState extends State<TrackerSectionScreen> {
|
|||
final box = await Hive.openBox("tracker_library");
|
||||
final key =
|
||||
"${widget.section.syncId}-${widget.section.itemType.name}-${widget.section.name}";
|
||||
if (!widget.section.isSearch && box.containsKey(key)) {
|
||||
final temp = box.get(key);
|
||||
if (temp is List<TrackSearch>) {
|
||||
_errorMessage = "";
|
||||
_tracks = temp;
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_checkCache(box, key)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
_errorMessage = "";
|
||||
|
|
@ -109,6 +99,23 @@ class _TrackerSectionScreenState extends State<TrackerSectionScreen> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _checkCache(Box<dynamic> box, String key) {
|
||||
if (!widget.section.isSearch && box.containsKey(key)) {
|
||||
final temp = box.get(key);
|
||||
if (temp is List<TrackSearch>) {
|
||||
_errorMessage = "";
|
||||
_tracks = temp;
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class SuperPrecalculationPolicy extends ExtentPrecalculationPolicy {
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ class MyAnimeList extends _$MyAnimeList {
|
|||
publishingStatus: res["status"].toString().replaceAll("_", " "),
|
||||
trackingUrl: "https://myanimelist.net/$item/${res["id"]}",
|
||||
score: res["mean"],
|
||||
syncId: syncId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue