extension & source widget fix
This commit is contained in:
parent
2ddbc0b40a
commit
44c5a54bbf
3 changed files with 189 additions and 106 deletions
|
|
@ -4,7 +4,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/utils/language.dart';
|
||||
import 'package:mangayomi/utils/media_query.dart';
|
||||
|
||||
class ExtensionDetail extends ConsumerWidget {
|
||||
final Source source;
|
||||
|
|
@ -20,24 +22,30 @@ class ExtensionDetail extends ConsumerWidget {
|
|||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: source.iconUrl!.isEmpty
|
||||
? const Icon(Icons.source_outlined, size: 100)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: source.iconUrl!,
|
||||
fit: BoxFit.contain,
|
||||
width: 100,
|
||||
height: 100,
|
||||
errorWidget: (context, url, error) {
|
||||
return const SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: Center(
|
||||
child: Icon(Icons.source_outlined, size: 100),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(context).secondaryHeaderColor.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
child: source.iconUrl!.isEmpty
|
||||
? const Icon(Icons.source_outlined, size: 140)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: source.iconUrl!,
|
||||
fit: BoxFit.contain,
|
||||
width: 140,
|
||||
height: 140,
|
||||
errorWidget: (context, url, error) {
|
||||
return const SizedBox(
|
||||
width: 140,
|
||||
height: 140,
|
||||
child: Center(
|
||||
child: Icon(Icons.source_outlined, size: 140),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
|
@ -48,81 +56,121 @@ class ExtensionDetail extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor(context).withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
source.version!,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
source.version!,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
l10n.version,
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
l10n.version,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
if (source.isNsfw!)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.7),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"NSFW (18+)",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white),
|
||||
),
|
||||
)),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
completeLanguageName(source.lang!),
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
l10n.language,
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
completeLanguageName(source.lang!),
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
l10n.language,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
source.name!,
|
||||
),
|
||||
content: Text(l10n.uninstall_extension(source.name!)),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
child: Text(l10n.cancel)),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
isar.writeTxnSync(
|
||||
() => isar.sources.putSync(source
|
||||
..sourceCode = ""
|
||||
..isAdded = false
|
||||
..isPinned = false
|
||||
..isNsfw = false));
|
||||
Navigator.pop(ctx);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(l10n.ok)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SizedBox(
|
||||
width: mediaWidth(context, 1),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.all(0),
|
||||
side:
|
||||
BorderSide(color: primaryColor(context), width: 0.3),
|
||||
backgroundColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
elevation: 0,
|
||||
shadowColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
source.name!,
|
||||
),
|
||||
content:
|
||||
Text(l10n.uninstall_extension(source.name!)),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
child: Text(l10n.cancel)),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
isar.writeTxnSync(
|
||||
() => isar.sources.putSync(source
|
||||
..sourceCode = ""
|
||||
..isAdded = false
|
||||
..isPinned = false));
|
||||
Navigator.pop(ctx);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(l10n.ok)),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
// if (res != null && res == true) {}
|
||||
},
|
||||
child: Text(l10n.uninstall))
|
||||
);
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
l10n.uninstall,
|
||||
style: const TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold),
|
||||
)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -85,21 +85,44 @@ class _ExtensionListTileWidgetState
|
|||
completeLanguageName(widget.source.lang!.toLowerCase()),
|
||||
style: const TextStyle(fontWeight: FontWeight.w300, fontSize: 12),
|
||||
),
|
||||
if (widget.source.isNsfw!)
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 2,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(widget.source.version!,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w300, fontSize: 10)),
|
||||
if (widget.source.isNsfw!)
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 2,
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.7),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: Text(
|
||||
"NSFW",
|
||||
style: TextStyle(
|
||||
fontSize: 6,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"18+",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w300,
|
||||
fontSize: 10,
|
||||
color: Colors.redAccent.withBlue(5).withOpacity(0.8)),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: TextButton(
|
||||
|
|
|
|||
|
|
@ -68,15 +68,27 @@ class SourceListTile extends StatelessWidget {
|
|||
const SizedBox(
|
||||
width: 2,
|
||||
),
|
||||
Text(
|
||||
"18+",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w300,
|
||||
fontSize: 10,
|
||||
color: Colors.redAccent.withBlue(5).withOpacity(0.8)),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.7),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: Text(
|
||||
"NSFW",
|
||||
style: TextStyle(
|
||||
fontSize: 6,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(source.name!),
|
||||
|
|
|
|||
Loading…
Reference in a new issue