chore: bump line length to 120 (#20191)

This commit is contained in:
shenlong
2025-07-25 08:07:22 +05:30
committed by GitHub
parent 977c9b96ba
commit ad65e9011a
517 changed files with 4520 additions and 9514 deletions
@@ -35,9 +35,7 @@ class AdvancedBottomSheet extends HookConsumerWidget {
const SizedBox(height: 32.0),
Container(
decoration: BoxDecoration(
color: context.isDarkTheme
? Colors.grey[900]
: Colors.grey[200],
color: context.isDarkTheme ? Colors.grey[900] : Colors.grey[200],
borderRadius: const BorderRadius.all(
Radius.circular(15.0),
),
@@ -66,8 +64,7 @@ class AdvancedBottomSheet extends HookConsumerWidget {
SnackBar(
content: Text(
"Copied to clipboard",
style:
context.textTheme.bodyLarge?.copyWith(
style: context.textTheme.bodyLarge?.copyWith(
color: context.primaryColor,
),
),
@@ -17,8 +17,7 @@ class AnimatedPlayPause extends StatefulWidget {
State<StatefulWidget> createState() => AnimatedPlayPauseState();
}
class AnimatedPlayPauseState extends State<AnimatedPlayPause>
with SingleTickerProviderStateMixin {
class AnimatedPlayPauseState extends State<AnimatedPlayPause> with SingleTickerProviderStateMixin {
late final animationController = AnimationController(
vsync: this,
value: widget.playing ? 1 : 0,
@@ -52,28 +52,21 @@ class BottomGalleryBar extends ConsumerWidget {
if (asset == null) {
return const SizedBox();
}
final isOwner =
asset.ownerId == fastHash(ref.watch(currentUserProvider)?.id ?? '');
final isOwner = asset.ownerId == fastHash(ref.watch(currentUserProvider)?.id ?? '');
final showControls = ref.watch(showControlsProvider);
final stackId = asset.stackId;
final stackItems = showStack && stackId != null
? ref.watch(assetStackStateProvider(stackId))
: <Asset>[];
final stackItems = showStack && stackId != null ? ref.watch(assetStackStateProvider(stackId)) : <Asset>[];
bool isStackPrimaryAsset = asset.stackPrimaryAssetId == null;
final navStack = AutoRouter.of(context).stackData;
final isTrashEnabled =
ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash));
final isFromTrash = isTrashEnabled &&
navStack.length > 2 &&
navStack.elementAt(navStack.length - 2).name == TrashRoute.name;
final isTrashEnabled = ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash));
final isFromTrash =
isTrashEnabled && navStack.length > 2 && navStack.elementAt(navStack.length - 2).name == TrashRoute.name;
final isInAlbum = ref.watch(currentAlbumProvider)?.isRemote ?? false;
void removeAssetFromStack() {
if (stackIndex.value > 0 && showStack && stackId != null) {
ref
.read(assetStackStateProvider(stackId).notifier)
.removeChild(stackIndex.value - 1);
ref.read(assetStackStateProvider(stackId).notifier).removeChild(stackIndex.value - 1);
}
}
@@ -89,8 +82,7 @@ class BottomGalleryBar extends ConsumerWidget {
// `assetIndex == totalAssets.value - 1` handle the case of removing the last asset
// to not throw the error when the next preCache index is called
if (totalAssets.value == 1 ||
assetIndex.value == totalAssets.value - 1) {
if (totalAssets.value == 1 || assetIndex.value == totalAssets.value - 1) {
// Handle only one asset
context.maybePop();
}
@@ -98,9 +90,7 @@ class BottomGalleryBar extends ConsumerWidget {
totalAssets.value -= 1;
}
if (isDeleted) {
ref
.read(currentAssetProvider.notifier)
.set(renderList.loadAsset(assetIndex.value));
ref.read(currentAssetProvider.notifier).set(renderList.loadAsset(assetIndex.value));
}
return isDeleted;
}
@@ -144,9 +134,7 @@ class BottomGalleryBar extends ConsumerWidget {
return;
}
await ref
.read(stackServiceProvider)
.deleteStack(asset.stackId!, stackItems);
await ref.read(stackServiceProvider).deleteStack(asset.stackId!, stackItems);
}
void showStackActionItems() {
@@ -240,8 +228,7 @@ class BottomGalleryBar extends ConsumerWidget {
handleRemoveFromAlbum() async {
final album = ref.read(currentAlbumProvider);
final bool isSuccess = album != null &&
await ref.read(albumProvider.notifier).removeAsset(album, [asset]);
final bool isSuccess = album != null && await ref.read(albumProvider.notifier).removeAsset(album, [asset]);
if (isSuccess) {
// Workaround for asset remaining in the gallery
@@ -373,9 +360,7 @@ class BottomGalleryBar extends ConsumerWidget {
unselectedItemColor: Colors.white,
showSelectedLabels: true,
showUnselectedLabels: true,
items: albumActions
.map((e) => e.keys.first)
.toList(growable: false),
items: albumActions.map((e) => e.keys.first).toList(growable: false),
onTap: (index) {
albumActions[index].values.first.call(index);
},
@@ -49,10 +49,8 @@ class CastDialog extends ConsumerWidget {
}
final devices = snapshot.data!;
final connected =
devices.where((d) => isCurrentDevice(d.$1)).toList();
final others =
devices.where((d) => !isCurrentDevice(d.$1)).toList();
final connected = devices.where((d) => isCurrentDevice(d.$1)).toList();
final others = devices.where((d) => !isCurrentDevice(d.$1)).toList();
final List<dynamic> sectionedList = [];
@@ -85,25 +83,18 @@ class CastDialog extends ConsumerWidget {
).tr(),
);
} else {
final (deviceName, type, deviceObj) =
item as (String, CastDestinationType, dynamic);
final (deviceName, type, deviceObj) = item as (String, CastDestinationType, dynamic);
return ListTile(
title: Text(
deviceName,
style: TextStyle(
color: isCurrentDevice(deviceName)
? context.colorScheme.primary
: null,
color: isCurrentDevice(deviceName) ? context.colorScheme.primary : null,
),
),
leading: Icon(
type == CastDestinationType.googleCast
? Icons.cast
: Icons.cast_connected,
color: isCurrentDevice(deviceName)
? context.colorScheme.primary
: null,
type == CastDestinationType.googleCast ? Icons.cast : Icons.cast_connected,
color: isCurrentDevice(deviceName) ? context.colorScheme.primary : null,
),
trailing: isCurrentDevice(deviceName)
? Icon(Icons.check, color: context.colorScheme.primary)
@@ -120,9 +111,7 @@ class CastDialog extends ConsumerWidget {
}
if (!isCurrentDevice(deviceName)) {
ref
.read(castProvider.notifier)
.connect(type, deviceObj);
ref.read(castProvider.notifier).connect(type, deviceObj);
}
},
);
@@ -24,8 +24,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
currentAssetProvider.select((asset) => asset != null && asset.isVideo),
);
final showControls = ref.watch(showControlsProvider);
final VideoPlaybackState state =
ref.watch(videoPlaybackValueProvider.select((value) => value.state));
final VideoPlaybackState state = ref.watch(videoPlaybackValueProvider.select((value) => value.state));
final cast = ref.watch(castProvider);
@@ -39,15 +38,12 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
final state = ref.read(videoPlaybackValueProvider).state;
// Do not hide on paused
if (state != VideoPlaybackState.paused &&
state != VideoPlaybackState.completed &&
assetIsVideo) {
if (state != VideoPlaybackState.paused && state != VideoPlaybackState.completed && assetIsVideo) {
ref.read(showControlsProvider.notifier).show = false;
}
},
);
final showBuffering =
state == VideoPlaybackState.buffering && !cast.isCasting;
final showBuffering = state == VideoPlaybackState.buffering && !cast.isCasting;
/// Shows the controls and starts the timer to hide them
void showControlsAndStartHideTimer() {
@@ -56,8 +52,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
}
// When we change position, show or hide timer
ref.listen(videoPlayerControlsProvider.select((v) => v.position),
(previous, next) {
ref.listen(videoPlayerControlsProvider.select((v) => v.position), (previous, next) {
showControlsAndStartHideTimer();
});
@@ -105,14 +100,13 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
)
else
GestureDetector(
onTap: () =>
ref.read(showControlsProvider.notifier).show = false,
onTap: () => ref.read(showControlsProvider.notifier).show = false,
child: CenterPlayButton(
backgroundColor: Colors.black54,
iconColor: Colors.white,
isFinished: state == VideoPlaybackState.completed,
isPlaying: state == VideoPlaybackState.playing ||
(cast.isCasting && cast.castState == CastState.playing),
isPlaying:
state == VideoPlaybackState.playing || (cast.isCasting && cast.castState == CastState.playing),
show: assetIsVideo && showControls,
onPressed: togglePlay,
),
@@ -24,10 +24,7 @@ class CameraInfo extends StatelessWidget {
"${exifInfo.make} ${exifInfo.model}",
style: context.textTheme.labelLarge,
),
subtitle: exifInfo.f != null ||
exifInfo.exposureSeconds != null ||
exifInfo.mm != null ||
exifInfo.iso != null
subtitle: exifInfo.f != null || exifInfo.exposureSeconds != null || exifInfo.mm != null || exifInfo.iso != null
? Text(
"ƒ/${exifInfo.fNumber} ${exifInfo.exposureTime} ${exifInfo.focalLength} mm ISO ${exifInfo.iso ?? ''} ",
style: context.textTheme.bodySmall,
@@ -24,9 +24,7 @@ class DetailPanel extends HookConsumerWidget {
child: Column(
children: [
AssetDateTime(asset: asset),
asset.isRemote
? DescriptionInput(asset: asset)
: const SizedBox.shrink(),
asset.isRemote ? DescriptionInput(asset: asset) : const SizedBox.shrink(),
PeopleInfo(asset: asset),
AssetLocation(asset: asset),
AssetDetails(asset: asset),
@@ -17,11 +17,8 @@ class FileInfo extends StatelessWidget {
final height = asset.orientatedHeight ?? asset.height;
final width = asset.orientatedWidth ?? asset.width;
String resolution =
height != null && width != null ? "$width x $height " : "";
String fileSize = asset.exifInfo?.fileSize != null
? formatBytes(asset.exifInfo!.fileSize!)
: "";
String resolution = height != null && width != null ? "$width x $height " : "";
String fileSize = asset.exifInfo?.fileSize != null ? formatBytes(asset.exifInfo!.fileSize!) : "";
String text = resolution + fileSize;
final imgSizeString = text.isNotEmpty ? text : null;
@@ -18,12 +18,8 @@ class PeopleInfo extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final peopleProvider =
ref.watch(assetPeopleNotifierProvider(asset).notifier);
final people = ref
.watch(assetPeopleNotifierProvider(asset))
.value
?.where((p) => !p.isHidden);
final peopleProvider = ref.watch(assetPeopleNotifierProvider(asset).notifier);
final people = ref.watch(assetPeopleNotifierProvider(asset)).value?.where((p) => !p.isHidden);
showPersonNameEditModel(
String personId,
@@ -46,8 +42,7 @@ class PeopleInfo extends ConsumerWidget {
(p) => SearchCuratedContent(
id: p.id,
label: p.name,
subtitle: p.birthDate != null &&
p.birthDate!.isBefore(asset.fileCreatedAt)
subtitle: p.birthDate != null && p.birthDate!.isBefore(asset.fileCreatedAt)
? _formatAge(p.birthDate!, asset.fileCreatedAt)
: null,
),
@@ -56,9 +51,7 @@ class PeopleInfo extends ConsumerWidget {
[];
return AnimatedCrossFade(
crossFadeState: (people?.isEmpty ?? true)
? CrossFadeState.showFirst
: CrossFadeState.showSecond,
crossFadeState: (people?.isEmpty ?? true) ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: const Duration(milliseconds: 200),
firstChild: Container(),
secondChild: Padding(
@@ -109,22 +102,18 @@ class PeopleInfo extends ConsumerWidget {
int ageInMonths = _calculateAgeInMonths(birthDate, referenceDate);
if (ageInMonths <= 11) {
return "exif_bottom_sheet_person_age_months"
.tr(namedArgs: {'months': ageInMonths.toString()});
return "exif_bottom_sheet_person_age_months".tr(namedArgs: {'months': ageInMonths.toString()});
} else if (ageInMonths > 12 && ageInMonths <= 23) {
return "exif_bottom_sheet_person_age_year_months"
.tr(namedArgs: {'months': (ageInMonths - 12).toString()});
return "exif_bottom_sheet_person_age_year_months".tr(namedArgs: {'months': (ageInMonths - 12).toString()});
} else {
return "exif_bottom_sheet_person_age_years"
.tr(namedArgs: {'years': ageInYears.toString()});
return "exif_bottom_sheet_person_age_years".tr(namedArgs: {'years': ageInYears.toString()});
}
}
int _calculateAge(DateTime birthDate, DateTime referenceDate) {
int age = referenceDate.year - birthDate.year;
if (referenceDate.month < birthDate.month ||
(referenceDate.month == birthDate.month &&
referenceDate.day < birthDate.day)) {
(referenceDate.month == birthDate.month && referenceDate.day < birthDate.day)) {
age--;
}
return age;
@@ -34,17 +34,12 @@ class GalleryAppBar extends ConsumerWidget {
return const SizedBox();
}
final album = ref.watch(currentAlbumProvider);
final isOwner =
asset.ownerId == fastHash(ref.watch(currentUserProvider)?.id ?? '');
final isOwner = asset.ownerId == fastHash(ref.watch(currentUserProvider)?.id ?? '');
final showControls = ref.watch(showControlsProvider);
final isPartner = ref
.watch(partnerSharedWithProvider)
.map((e) => fastHash(e.id))
.contains(asset.ownerId);
final isPartner = ref.watch(partnerSharedWithProvider).map((e) => fastHash(e.id)).contains(asset.ownerId);
toggleFavorite(Asset asset) =>
ref.read(assetProvider.notifier).toggleFavorite([asset]);
toggleFavorite(Asset asset) => ref.read(assetProvider.notifier).toggleFavorite([asset]);
handleActivities() {
if (album != null && album.shared && album.remoteId != null) {
@@ -53,8 +48,7 @@ class GalleryAppBar extends ConsumerWidget {
}
handleRestore(Asset asset) async {
final result =
await ref.read(trashProvider.notifier).restoreAssets([asset]);
final result = await ref.read(trashProvider.notifier).restoreAssets([asset]);
if (result && context.mounted) {
ImmichToast.show(
@@ -71,9 +65,7 @@ class GalleryAppBar extends ConsumerWidget {
builder: (BuildContext _) {
return UploadDialog(
onUpload: () {
ref
.read(manualUploadProvider.notifier)
.uploadAssets(context, [asset]);
ref.read(manualUploadProvider.notifier).uploadAssets(context, [asset]);
},
);
},
@@ -104,8 +96,7 @@ class GalleryAppBar extends ConsumerWidget {
handleLocateAsset() async {
// Go back to the gallery
await context.maybePop();
await context
.navigateTo(const TabControllerRoute(children: [PhotosRoute()]));
await context.navigateTo(const TabControllerRoute(children: [PhotosRoute()]));
ref.read(tabProvider.notifier).update((state) => state = TabEnum.home);
// Scroll to the asset's date
scrollToDateNotifierProvider.scrollToDate(asset.fileCreatedAt);
@@ -49,12 +49,9 @@ class TopControlAppBar extends HookConsumerWidget {
final a = ref.watch(assetWatcher(asset)).value ?? asset;
final album = ref.watch(currentAlbumProvider);
final isCasting = ref.watch(castProvider.select((c) => c.isCasting));
final websocketConnected =
ref.watch(websocketProvider.select((c) => c.isConnected));
final websocketConnected = ref.watch(websocketProvider.select((c) => c.isConnected));
final comments = album != null &&
album.remoteId != null &&
asset.remoteId != null
final comments = album != null && album.remoteId != null && asset.remoteId != null
? ref.watch(activityStatisticsProvider(album.remoteId!, asset.remoteId))
: 0;
@@ -204,24 +201,14 @@ class TopControlAppBar extends HookConsumerWidget {
shape: const Border(),
actions: [
if (asset.isRemote && isOwner) buildFavoriteButton(a),
if (isOwner &&
!isInHomePage &&
!(isInTrash ?? false) &&
!isInLockedView)
buildLocateButton(),
if (isOwner && !isInHomePage && !(isInTrash ?? false) && !isInLockedView) buildLocateButton(),
if (asset.livePhotoVideoId != null) const MotionPhotoButton(),
if (asset.isLocal && !asset.isRemote) buildUploadButton(),
if (asset.isRemote && !asset.isLocal && isOwner) buildDownloadButton(),
if (asset.isRemote &&
(isOwner || isPartner) &&
!asset.isTrashed &&
!isInLockedView)
buildAddToAlbumButton(),
if (isCasting || (asset.isRemote && websocketConnected))
buildCastButton(),
if (asset.isRemote && (isOwner || isPartner) && !asset.isTrashed && !isInLockedView) buildAddToAlbumButton(),
if (isCasting || (asset.isRemote && websocketConnected)) buildCastButton(),
if (asset.isTrashed) buildRestoreButton(),
if (album != null && album.shared && !isInLockedView)
buildActivitiesButton(),
if (album != null && album.shared && !isInLockedView) buildActivitiesButton(),
buildMoreInfoButton(),
],
);
@@ -54,8 +54,7 @@ class VideoPosition extends HookConsumerWidget {
activeColor: Colors.white,
inactiveColor: whiteOpacity75,
onChangeStart: (value) {
final state =
ref.read(videoPlaybackValueProvider).state;
final state = ref.read(videoPlaybackValueProvider).state;
wasPlaying.value = state != VideoPlaybackState.paused;
ref.read(videoPlayerControlsProvider.notifier).pause();
},
@@ -68,19 +67,14 @@ class VideoPosition extends HookConsumerWidget {
final seekToDuration = (duration * (value / 100.0));
if (isCasting) {
ref
.read(castProvider.notifier)
.seekTo(seekToDuration);
ref.read(castProvider.notifier).seekTo(seekToDuration);
return;
}
ref
.read(videoPlayerControlsProvider.notifier)
.position = seekToDuration.inSeconds.toDouble();
ref.read(videoPlayerControlsProvider.notifier).position = seekToDuration.inSeconds.toDouble();
// This immediately updates the slider position without waiting for the video to update
ref.read(videoPlaybackValueProvider.notifier).position =
seekToDuration;
ref.read(videoPlaybackValueProvider.notifier).position = seekToDuration;
},
),
),