Code improvements

This commit is contained in:
Juan Gilsanz Polo
2025-04-03 22:26:14 +02:00
parent 7982644c23
commit 93ebb1de40
17 changed files with 114 additions and 107 deletions

View File

@@ -12,5 +12,6 @@
"Linkding",
"linkdy",
"Linkdy"
]
],
"cSpell.language": "en,es,tr",
}

View File

@@ -208,14 +208,14 @@ class _ConnectForm extends ConsumerWidget {
onPressed: provider.testConnection == null ? () => ref.read(connectProvider.notifier).testConnection() : null,
style: ButtonStyle(
foregroundColor: provider.testConnection == LoadStatus.loaded
? const MaterialStatePropertyAll(Colors.green)
? const WidgetStatePropertyAll(Colors.green)
: provider.testConnection == LoadStatus.error
? const MaterialStatePropertyAll(Colors.red)
? const WidgetStatePropertyAll(Colors.red)
: null,
backgroundColor: provider.testConnection == LoadStatus.loaded
? MaterialStatePropertyAll(Colors.green.withOpacity(0.15))
? WidgetStatePropertyAll(Colors.green.withOpacity(0.15))
: provider.testConnection == LoadStatus.error
? MaterialStatePropertyAll(Colors.red.withOpacity(0.15))
? WidgetStatePropertyAll(Colors.red.withOpacity(0.15))
: null,
),
child: Row(

View File

@@ -15,7 +15,7 @@ class ColorItem extends StatelessWidget {
required this.color,
required this.numericValue,
required this.selectedValue,
required this.onChanged
required this.onChanged,
});
@override
@@ -31,13 +31,13 @@ class ColorItem extends StatelessWidget {
child: InkWell(
onTap: () => onChanged(numericValue),
borderRadius: BorderRadius.circular(50),
overlayColor: const MaterialStatePropertyAll(Colors.grey),
overlayColor: const WidgetStatePropertyAll(Colors.grey),
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(50)
borderRadius: BorderRadius.circular(50),
),
child: AnimatedOpacity(
opacity: numericValue == selectedValue ? 1 : 0,

View File

@@ -9,14 +9,14 @@ class ThemeModeButton extends StatelessWidget {
final bool? disabled;
const ThemeModeButton({
Key? key,
super.key,
required this.icon,
required this.value,
required this.selected,
required this.label,
required this.onChanged,
this.disabled
}) : super(key: key);
this.disabled,
});
@override
Widget build(BuildContext context) {
@@ -28,25 +28,23 @@ class ThemeModeButton extends StatelessWidget {
: const Color.fromRGBO(100, 100, 100, 1);
return ElevatedButton(
onPressed: disabled == null || disabled == false
? () => onChanged(value)
: null,
onPressed: disabled == null || disabled == false ? () => onChanged(value) : null,
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
shape: MaterialStateProperty.all(
elevation: WidgetStateProperty.all(0),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
)
),
backgroundColor: MaterialStateProperty.all(
),
backgroundColor: WidgetStateProperty.all(
value == selected
? disabled == null || disabled == false
? Theme.of(context).colorScheme.primary
: greyBackgroundColor
: disabled == null || disabled == false
? Theme.of(context).colorScheme.surfaceVariant
? Theme.of(context).colorScheme.surfaceContainerHighest
: greyBackgroundColor,
)
),
),
child: AnimatedContainer(
width: 118,
@@ -60,7 +58,9 @@ class ThemeModeButton extends StatelessWidget {
icon,
color: value == selected
? disabled == null || disabled == false
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5
? Colors.black
: Colors.white
: greyIconColor
: disabled == null || disabled == false
? Theme.of(context).colorScheme.primary
@@ -72,14 +72,16 @@ class ThemeModeButton extends StatelessWidget {
style: TextStyle(
color: value == selected
? disabled == null || disabled == false
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5
? Colors.black
: Colors.white
: greyIconColor
: disabled == null || disabled == false
? Theme.of(context).colorScheme.primary
: greyIconColor,
fontSize: 18
fontSize: 18,
),
),
)
],
),
),

View File

@@ -5,7 +5,7 @@ import 'package:linkdy/i18n/strings.g.dart';
import 'package:linkdy/providers/api_client.provider.dart';
class DisconnectModal extends ConsumerWidget {
const DisconnectModal({Key? key}) : super(key: key);
const DisconnectModal({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {

View File

@@ -101,8 +101,8 @@ class GeneralSettings extends ConsumerWidget {
t.settings.generalSettings.disconnectFromServer,
),
style: const ButtonStyle(
foregroundColor: MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(Colors.red),
foregroundColor: WidgetStatePropertyAll(Colors.white),
backgroundColor: WidgetStatePropertyAll(Colors.red),
),
),
],

View File

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:linkdy/i18n/strings.g.dart';
class AddTagErrorModal extends StatelessWidget {
const AddTagErrorModal({Key? key}) : super(key: key);
const AddTagErrorModal({super.key});
@override
Widget build(BuildContext context) {

View File

@@ -14,7 +14,7 @@ class CustomListTile extends StatelessWidget {
final Color? color;
const CustomListTile({
Key? key,
super.key,
required this.title,
this.subtitle,
this.subtitleWidget,
@@ -26,7 +26,7 @@ class CustomListTile extends StatelessWidget {
this.disabled,
this.onHover,
this.color,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@@ -80,16 +80,17 @@ class CustomListTile extends StatelessWidget {
? Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38)
: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 14,
fontWeight: FontWeight.w400),
fontWeight: FontWeight.w400,
),
),
]
],
),
)
],
),
),
if (trailing != null) ...[const SizedBox(width: 16), trailing!]
],
),
),
if (trailing != null) ...[const SizedBox(width: 16), trailing!],
],
),
),

View File

@@ -62,16 +62,17 @@ class CustomSettingsTile extends StatelessWidget {
style: TextStyle(
color: Theme.of(context).listTileTheme.textColor,
fontSize: 14,
fontWeight: FontWeight.w400),
fontWeight: FontWeight.w400,
),
),
]
],
),
)
],
),
),
if (trailing != null) ...[const SizedBox(width: 10), trailing!]
],
),
),
if (trailing != null) ...[const SizedBox(width: 10), trailing!],
],
);
@@ -88,8 +89,10 @@ class CustomSettingsTile extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(28),
color: thisItem == selectedItem ? Theme.of(context).colorScheme.primaryContainer : null),
child: tileBody),
color: thisItem == selectedItem ? Theme.of(context).colorScheme.primaryContainer : null,
),
child: tileBody,
),
),
),
);

View File

@@ -25,12 +25,14 @@ class CustomSwitchListTile extends StatelessWidget {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: disabled != null && disabled == true
? null
: () => onChanged(!value),
onTap: disabled != null && disabled == true ? null : () => onChanged(!value),
child: Padding(
padding: padding ?? const EdgeInsets.only(
top: 12, left: 16, right: 18, bottom: 16
padding: padding ??
const EdgeInsets.only(
top: 12,
left: 16,
right: 18,
bottom: 16,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -65,21 +67,19 @@ class CustomSwitchListTile extends StatelessWidget {
fontSize: 14,
color: disabled != null && disabled == true
? Theme.of(context).listTileTheme.textColor!.withOpacity(0.38)
: Theme.of(context).listTileTheme.textColor
: Theme.of(context).listTileTheme.textColor,
),
),
),
]
],
],
),
),
const SizedBox(width: 16),
Switch(
value: value,
onChanged: disabled != null && disabled == true
? null
: onChanged,
)
onChanged: disabled != null && disabled == true ? null : onChanged,
),
],
),
),

View File

@@ -4,9 +4,9 @@ class EnterSearchTermScreen extends StatelessWidget {
final String message;
const EnterSearchTermScreen({
Key? key,
super.key,
required this.message,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -4,9 +4,9 @@ class ErrorScreen extends StatelessWidget {
final String error;
const ErrorScreen({
Key? key,
super.key,
required this.error,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -4,9 +4,9 @@ class NoDataScreen extends StatelessWidget {
final String message;
const NoDataScreen({
Key? key,
super.key,
required this.message,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -5,9 +5,9 @@ class PageTransition extends StatelessWidget {
final Widget child;
const PageTransition({
Key? key,
super.key,
required this.child,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -4,9 +4,9 @@ class ProcessDialog extends StatelessWidget {
final String message;
const ProcessDialog({
Key? key,
super.key,
required this.message,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@@ -29,7 +29,7 @@ class ProcessDialog extends StatelessWidget {
message,
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
),
)
),
],
),
),

View File

@@ -5,10 +5,10 @@ class SectionLabel extends StatelessWidget {
final EdgeInsets? padding;
const SectionLabel({
Key? key,
super.key,
required this.label,
this.padding,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
class SliverTabBody extends StatelessWidget {
final Widget child;
const SliverTabBody({Key? key, required this.child}) : super(key: key);
const SliverTabBody({super.key, required this.child});
@override
Widget build(BuildContext context) {
@@ -28,10 +28,10 @@ class SliverTabBodyRefresh extends StatelessWidget {
final Future<void> Function() onRefresh;
const SliverTabBodyRefresh({
Key? key,
super.key,
required this.child,
required this.onRefresh,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {