Code improvements
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -12,5 +12,6 @@
|
||||
"Linkding",
|
||||
"linkdy",
|
||||
"Linkdy"
|
||||
]
|
||||
],
|
||||
"cSpell.language": "en,es,tr",
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -15,29 +15,29 @@ class ColorItem extends StatelessWidget {
|
||||
required this.color,
|
||||
required this.numericValue,
|
||||
required this.selectedValue,
|
||||
required this.onChanged
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: index == 0
|
||||
? const EdgeInsets.only(top: 10, right: 10, bottom: 10)
|
||||
: index == total-1
|
||||
? const EdgeInsets.only(top: 10, bottom: 10, left: 10)
|
||||
: const EdgeInsets.all(10),
|
||||
? const EdgeInsets.only(top: 10, right: 10, bottom: 10)
|
||||
: index == total - 1
|
||||
? const EdgeInsets.only(top: 10, bottom: 10, left: 10)
|
||||
: const EdgeInsets.all(10),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
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,
|
||||
|
||||
@@ -9,44 +9,42 @@ 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) {
|
||||
final Color greyBackgroundColor = Theme.of(context).brightness == Brightness.light
|
||||
?const Color.fromRGBO(200, 200, 200, 1)
|
||||
:const Color.fromRGBO(50, 50, 50, 1);
|
||||
? const Color.fromRGBO(200, 200, 200, 1)
|
||||
: const Color.fromRGBO(50, 50, 50, 1);
|
||||
final Color greyIconColor = Theme.of(context).brightness == Brightness.light
|
||||
? const Color.fromRGBO(130, 130, 130, 1)
|
||||
: const Color.fromRGBO(100, 100, 100, 1);
|
||||
? const Color.fromRGBO(130, 130, 130, 1)
|
||||
: 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
|
||||
: greyBackgroundColor,
|
||||
)
|
||||
? disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: greyBackgroundColor
|
||||
: disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.surfaceContainerHighest
|
||||
: greyBackgroundColor,
|
||||
),
|
||||
),
|
||||
child: AnimatedContainer(
|
||||
width: 118,
|
||||
@@ -59,27 +57,31 @@ class ThemeModeButton extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
color: value == selected
|
||||
? disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
||||
: greyIconColor
|
||||
: disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: greyIconColor,
|
||||
? disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5
|
||||
? Colors.black
|
||||
: Colors.white
|
||||
: greyIconColor
|
||||
: disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: greyIconColor,
|
||||
size: 30,
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: value == selected
|
||||
? disabled == null || disabled == false
|
||||
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
||||
: greyIconColor
|
||||
? disabled == null || disabled == false
|
||||
? 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
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: greyIconColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
@@ -76,20 +76,21 @@ class CustomListTile extends StatelessWidget {
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
color: disabled == true
|
||||
? Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
color: disabled == true
|
||||
? Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[const SizedBox(width: 16), trailing!]
|
||||
if (trailing != null) ...[const SizedBox(width: 16), trailing!],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -60,18 +60,19 @@ class CustomSettingsTile extends StatelessWidget {
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[const SizedBox(width: 10), trailing!]
|
||||
if (trailing != null) ...[const SizedBox(width: 10), trailing!],
|
||||
],
|
||||
);
|
||||
|
||||
@@ -84,12 +85,14 @@ class CustomSettingsTile extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
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),
|
||||
width: double.maxFinite,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -25,13 +25,15 @@ 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,
|
||||
children: [
|
||||
@@ -55,31 +57,29 @@ class CustomSwitchListTile extends StatelessWidget {
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (subtitle != null) ... [
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 5),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width-110,
|
||||
width: MediaQuery.of(context).size.width - 110,
|
||||
child: Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
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!.withOpacity(0.38)
|
||||
: 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user