Skip to content

Commit c04268c

Browse files
committed
fix: local notification dependency
- Cleaned dart analysis
1 parent 12a2192 commit c04268c

20 files changed

Lines changed: 193 additions & 355 deletions

lib/components/appbars/root_search_app_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class _RootSearchAppBarState extends State<RootSearchAppBar> {
104104
),
105105
title: Text(
106106
appStrings.tabBar_albums,
107-
textScaleFactor: 1,
107+
textScaler: TextScaler.linear(1),
108108
style: Theme.of(context).appBarTheme.titleTextStyle,
109109
),
110110
),

lib/components/appbars/settings_app_bar.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
3333
}
3434

3535
// In case 0%-100% of the expanded height is viewed
36-
double scrollDelta =
37-
(_expandedHeight - widget.scrollController.offset) / _expandedHeight;
36+
double scrollDelta = (_expandedHeight - widget.scrollController.offset) / _expandedHeight;
3837
double scrollPercent = (scrollDelta * 2 - 1);
3938
return (1 - scrollPercent) * delta * basePadding + basePadding;
4039
}
@@ -59,7 +58,7 @@ class _SettingsAppBarState extends State<SettingsAppBar> {
5958
),
6059
title: Text(
6160
appStrings.tabBar_preferences,
62-
textScaleFactor: 1,
61+
textScaler: TextScaler.linear(1),
6362
style: Theme.of(context).appBarTheme.titleTextStyle,
6463
),
6564
),

lib/components/cards/image_details_card.dart

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:io';
2-
import 'dart:ui' as ui show Codec, FrameInfo, Image;
2+
import 'dart:ui' as ui show Image;
33

44
import 'package:auto_size_text/auto_size_text.dart';
55
import 'package:extended_text/extended_text.dart';
@@ -17,8 +17,7 @@ import 'package:provider/provider.dart';
1717
import 'package:video_player/video_player.dart';
1818

1919
class ImageDetailsCard extends StatelessWidget {
20-
const ImageDetailsCard({Key? key, required this.image, this.onRemove})
21-
: super(key: key);
20+
const ImageDetailsCard({Key? key, required this.image, this.onRemove}) : super(key: key);
2221

2322
final ImageModel image;
2423
final Function()? onRemove;
@@ -57,9 +56,7 @@ class ImageDetailsCard extends StatelessWidget {
5756
child: ClipRRect(
5857
borderRadius: BorderRadius.circular(5.0),
5958
child: Builder(builder: (context) {
60-
final String? imageUrl = image
61-
.getDerivativeFromString(Preferences.getImageThumbnailSize)
62-
?.url;
59+
final String? imageUrl = image.getDerivativeFromString(Preferences.getImageThumbnailSize)?.url;
6360
return ImageNetworkDisplay(
6461
imageUrl: imageUrl,
6562
);
@@ -91,10 +88,7 @@ class ImageDetailsCard extends StatelessWidget {
9188
children: [
9289
Flexible(
9390
child: Text(
94-
image.file
95-
.replaceAll('', '\u200B')
96-
.split(path.extension(image.file))
97-
.first,
91+
image.file.replaceAll('', '\u200B').split(path.extension(image.file)).first,
9892
maxLines: 1,
9993
overflow: TextOverflow.ellipsis,
10094
style: Theme.of(context).textTheme.bodySmall,
@@ -112,13 +106,11 @@ class ImageDetailsCard extends StatelessWidget {
112106
const Spacer(),
113107
if (image.dateAvailable != null)
114108
Builder(builder: (context) {
115-
LocaleNotifier localeNotifier =
116-
Provider.of<LocaleNotifier>(context, listen: false);
109+
LocaleNotifier localeNotifier = Provider.of<LocaleNotifier>(context, listen: false);
117110
String date =
118-
DateFormat.yMMMMd(localeNotifier.locale.languageCode)
119-
.format(DateTime.parse(image.dateAvailable!));
120-
String time = DateFormat.Hms(localeNotifier.locale.languageCode)
121-
.format(DateTime.parse(image.dateAvailable!));
111+
DateFormat.yMMMMd(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
112+
String time =
113+
DateFormat.Hms(localeNotifier.locale.languageCode).format(DateTime.parse(image.dateAvailable!));
122114
return AutoSizeText(
123115
"$date $time",
124116
maxLines: 1,
@@ -150,8 +142,7 @@ class ImageDetailsCard extends StatelessWidget {
150142
}
151143

152144
class LocalImageDetailsCard extends StatefulWidget {
153-
const LocalImageDetailsCard(
154-
{Key? key, required this.image, this.onRemove, this.isDuplicate = false})
145+
const LocalImageDetailsCard({Key? key, required this.image, this.onRemove, this.isDuplicate = false})
155146
: super(key: key);
156147

157148
final File image;
@@ -214,17 +205,12 @@ class _LocalImageDetailsCardState extends State<LocalImageDetailsCard> {
214205
fit: StackFit.expand,
215206
children: [
216207
LayoutBuilder(builder: (context, constraints) {
217-
List<String>? mimeType =
218-
mime(widget.image.path.split('/').last)?.split('/');
208+
List<String>? mimeType = mime(widget.image.path.split('/').last)?.split('/');
219209

220210
if (mimeType?.first == 'image') {
221211
_checkMemory();
222-
double? cacheWidth = constraints.maxWidth.isInfinite
223-
? constraints.maxWidth
224-
: null;
225-
double? cacheHeight = constraints.maxHeight.isInfinite
226-
? constraints.maxHeight
227-
: null;
212+
double? cacheWidth = constraints.maxWidth.isInfinite ? constraints.maxWidth : null;
213+
double? cacheHeight = constraints.maxHeight.isInfinite ? constraints.maxHeight : null;
228214
return Image.file(
229215
widget.image,
230216
fit: BoxFit.cover,
@@ -327,8 +313,7 @@ class _LocalImageDetailsCardState extends State<LocalImageDetailsCard> {
327313
}
328314

329315
class LocalVideoDetailsCard extends StatefulWidget {
330-
const LocalVideoDetailsCard(
331-
{Key? key, required this.video, this.onRemove, this.isDuplicate = false})
316+
const LocalVideoDetailsCard({Key? key, required this.video, this.onRemove, this.isDuplicate = false})
332317
: super(key: key);
333318

334319
final File video;
@@ -361,9 +346,7 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
361346
final Duration duration = _controller.value.duration;
362347
int hours = duration.inHours;
363348
int minutes = (duration - Duration(hours: hours)).inMinutes;
364-
int seconds =
365-
(duration - Duration(hours: hours) - Duration(minutes: minutes))
366-
.inSeconds;
349+
int seconds = (duration - Duration(hours: hours) - Duration(minutes: minutes)).inSeconds;
367350
return '${hours > 0 ? '$hours:' : ''}${minutes < 10 ? '0$minutes' : '$minutes'}:${seconds < 10 ? '0$seconds' : '$seconds'}';
368351
}
369352

@@ -433,17 +416,12 @@ class _LocalVideoDetailsCardState extends State<LocalVideoDetailsCard> {
433416
bottom: 2.0,
434417
left: 2.0,
435418
child: Container(
436-
padding: const EdgeInsets.symmetric(
437-
horizontal: 4, vertical: 2),
419+
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
438420
decoration: BoxDecoration(
439-
borderRadius: BorderRadius.circular(5),
440-
color: AppColors.black.withOpacity(0.7)),
421+
borderRadius: BorderRadius.circular(5), color: AppColors.black.withOpacity(0.7)),
441422
child: Text(
442423
_duration,
443-
style: TextStyle(
444-
color: AppColors.white,
445-
fontSize: 10,
446-
fontWeight: FontWeight.bold),
424+
style: TextStyle(color: AppColors.white, fontSize: 10, fontWeight: FontWeight.bold),
447425
),
448426
),
449427
),

lib/components/dialogs/confirm_dialog.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ class ConfirmDialog extends StatelessWidget {
2727
actions: [
2828
TextButton(
2929
style: ButtonStyle(
30-
foregroundColor: MaterialStateColor.resolveWith(
31-
(states) =>
32-
Theme.of(context).textTheme.bodySmall?.color ??
33-
AppColors.disabled,
30+
foregroundColor: WidgetStateColor.resolveWith(
31+
(states) => Theme.of(context).textTheme.bodySmall?.color ?? AppColors.disabled,
3432
),
35-
overlayColor: MaterialStateColor.resolveWith(
33+
overlayColor: WidgetStateColor.resolveWith(
3634
(states) => AppColors.accent.withOpacity(0.3),
3735
),
3836
),
@@ -43,10 +41,10 @@ class ConfirmDialog extends StatelessWidget {
4341
),
4442
TextButton(
4543
style: ButtonStyle(
46-
foregroundColor: MaterialStateColor.resolveWith(
44+
foregroundColor: WidgetStateColor.resolveWith(
4745
(states) => confirmColor ?? AppColors.accent,
4846
),
49-
overlayColor: MaterialStateColor.resolveWith(
47+
overlayColor: WidgetStateColor.resolveWith(
5048
(states) => AppColors.accent.withOpacity(0.3),
5149
),
5250
),

lib/components/modals/move_or_copy_modal.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class MoveOrCopyModal extends StatefulWidget {
2626
}
2727

2828
class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
29-
final ScrollController _scrollController = ScrollController();
3029
late final Future<ApiResponse<List<AlbumModel>>> _albumFuture;
3130
late final List<int> _disabledAlbums;
3231

@@ -39,8 +38,7 @@ class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
3938
_disabledAlbums = [
4039
if (widget.album != null) widget.album!.id,
4140
if (parentAlbums.length == 1 || widget.isImage) 0,
42-
if (!widget.isImage && parentAlbums.length > 1)
43-
int.parse(parentAlbums[parentAlbums.length - 2]),
41+
if (!widget.isImage && parentAlbums.length > 1) int.parse(parentAlbums[parentAlbums.length - 2]),
4442
];
4543

4644
super.initState();
@@ -213,9 +211,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
213211
child: Text(
214212
"${List.generate(widget.index, (index) => '.').join()}${widget.index > 0 ? ' ' : ''}${widget.album.name}",
215213
overflow: TextOverflow.ellipsis,
216-
style: _disabled
217-
? Theme.of(context).textTheme.bodySmall
218-
: Theme.of(context).textTheme.bodyMedium,
214+
style: _disabled ? Theme.of(context).textTheme.bodySmall : Theme.of(context).textTheme.bodyMedium,
219215
),
220216
),
221217
),
@@ -235,9 +231,7 @@ class _ExpansionAlbumTileState extends State<ExpansionAlbumTile> {
235231
child: Text(
236232
appStrings.albumCount(widget.album.nbCategories),
237233
style: TextStyle(
238-
color: Theme.of(context)
239-
.primaryColor
240-
.withOpacity(0.7),
234+
color: Theme.of(context).primaryColor.withOpacity(0.7),
241235
fontSize: 14,
242236
),
243237
),

lib/services/notification_service.dart

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ import 'package:piwigo_ng/utils/localizations.dart';
1010
import 'package:piwigo_ng/utils/settings.dart';
1111
import 'package:shared_preferences/shared_preferences.dart';
1212

13-
final FlutterLocalNotificationsPlugin localNotification =
14-
FlutterLocalNotificationsPlugin();
13+
final FlutterLocalNotificationsPlugin localNotification = FlutterLocalNotificationsPlugin();
1514

1615
Future<void> initLocalNotifications() async {
17-
const AndroidInitializationSettings initializationSettingsAndroid =
18-
AndroidInitializationSettings(
16+
const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings(
1917
'@mipmap/ic_launcher',
2018
);
21-
final initSettings =
22-
InitializationSettings(android: initializationSettingsAndroid);
19+
final initSettings = InitializationSettings(android: initializationSettingsAndroid);
2320
localNotification.initialize(
2421
initSettings,
2522
onDidReceiveNotificationResponse: onSelectNotification,
@@ -36,9 +33,8 @@ Future<void> onSelectNotification(NotificationResponse response) async {
3633

3734
Future<bool?> askNotificationPermissions() async {
3835
return localNotification
39-
.resolvePlatformSpecificImplementation<
40-
AndroidFlutterLocalNotificationsPlugin>()
41-
?.requestPermission();
36+
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
37+
?.requestNotificationsPermission();
4238
}
4339

4440
Future<void> showLocalNotification({
@@ -88,9 +84,7 @@ Future<void> showUploadNotification([int nbError = 0, int nbImage = 0]) async {
8884
} else if (nbError == 0 && nbImage > 0) {
8985
// Upload completed
9086
title = appStrings.imageUploadCompleted_title;
91-
message = nbImage == 1
92-
? appStrings.imageUploadCompleted_message
93-
: appStrings.imageUploadCompleted_message1;
87+
message = nbImage == 1 ? appStrings.imageUploadCompleted_message : appStrings.imageUploadCompleted_message1;
9488
} else if (nbError > 0 && nbImage != nbError) {
9589
// Upload partially completed
9690
title = appStrings.coreDataStore_WarningTitle;
@@ -118,10 +112,8 @@ Future<void> showAutoUploadNotification([
118112
if (!(prefs.getBool(AutoUploadPreferences.notificationKey) ?? false)) return;
119113

120114
// Find localizations
121-
Locale locale = Locale(prefs.getString(LocaleNotifier.key) ??
122-
Platform.localeName.split('_').first);
123-
AppLocalizations backgroundStrings =
124-
await AppLocalizations.delegate.load(locale);
115+
Locale locale = Locale(prefs.getString(LocaleNotifier.key) ?? Platform.localeName.split('_').first);
116+
AppLocalizations backgroundStrings = await AppLocalizations.delegate.load(locale);
125117

126118
// Init notifications
127119
final android = AndroidNotificationDetails(
@@ -139,9 +131,8 @@ Future<void> showAutoUploadNotification([
139131
if (nbError == 0 && nbImage > 0) {
140132
// Upload completed
141133
title = backgroundStrings.imageUploadCompleted_title;
142-
message = nbImage == 1
143-
? backgroundStrings.imageUploadCompleted_message
144-
: backgroundStrings.imageUploadCompleted_message1;
134+
message =
135+
nbImage == 1 ? backgroundStrings.imageUploadCompleted_message : backgroundStrings.imageUploadCompleted_message1;
145136
} else if (nbError > 0 && nbImage != nbError) {
146137
// Upload partially completed
147138
title = backgroundStrings.coreDataStore_WarningTitle;

lib/utils/themes.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final ThemeData lightTheme = ThemeData.light(useMaterial3: true).copyWith(
1919
primary: AppColors.white,
2020
secondary: AppColors.accent,
2121
error: AppColors.error,
22-
background: AppColors.backgroundLight,
22+
surface: AppColors.backgroundLight,
2323
outline: AppColors.fieldLight,
2424
),
2525
progressIndicatorTheme: const ProgressIndicatorThemeData(
@@ -101,12 +101,12 @@ final ThemeData lightTheme = ThemeData.light(useMaterial3: true).copyWith(
101101
backgroundColor: Colors.black.withOpacity(0),
102102
),
103103
switchTheme: SwitchThemeData(
104-
thumbColor: MaterialStateProperty.all(AppColors.backgroundLight),
105-
overlayColor: MaterialStateProperty.all(AppColors.backgroundLight),
106-
trackColor: MaterialStateProperty.resolveWith((states) {
107-
if (states.contains(MaterialState.selected)) {
104+
thumbColor: WidgetStateProperty.all(AppColors.backgroundLight),
105+
overlayColor: WidgetStateProperty.all(AppColors.backgroundLight),
106+
trackColor: WidgetStateProperty.resolveWith((states) {
107+
if (states.contains(WidgetState.selected)) {
108108
return AppColors.accent;
109-
} else if (states.contains(MaterialState.disabled)) {
109+
} else if (states.contains(WidgetState.disabled)) {
110110
return AppColors.disabled;
111111
}
112112
return AppColors.fieldLight;
@@ -190,7 +190,7 @@ final ThemeData darkTheme = ThemeData.dark(useMaterial3: true).copyWith(
190190
primary: AppColors.white,
191191
secondary: AppColors.accent,
192192
error: AppColors.error,
193-
background: AppColors.backgroundDark,
193+
surface: AppColors.backgroundDark,
194194
outline: AppColors.fieldDark,
195195
),
196196
progressIndicatorTheme: const ProgressIndicatorThemeData(
@@ -272,11 +272,11 @@ final ThemeData darkTheme = ThemeData.dark(useMaterial3: true).copyWith(
272272
backgroundColor: Colors.black.withOpacity(0),
273273
),
274274
switchTheme: SwitchThemeData(
275-
thumbColor: MaterialStateProperty.all(const Color(0x80FFFFFF)),
276-
trackColor: MaterialStateProperty.resolveWith((states) {
277-
if (states.contains(MaterialState.selected)) {
275+
thumbColor: WidgetStateProperty.all(const Color(0x80FFFFFF)),
276+
trackColor: WidgetStateProperty.resolveWith((states) {
277+
if (states.contains(WidgetState.selected)) {
278278
return AppColors.accent;
279-
} else if (states.contains(MaterialState.disabled)) {
279+
} else if (states.contains(WidgetState.disabled)) {
280280
return AppColors.disabled;
281281
}
282282
return AppColors.backgroundDark;

0 commit comments

Comments
 (0)