mirror of
https://github.com/samsonjs/immich.git
synced 2026-03-25 09:15:56 +00:00
fix(mobile): hide latest version warnings (#26036)
The latest version is already hidden in the server info widget if disabled (https://github.com/immich-app/immich/pull/25691), however I did not realise there are more places where this warning is shown. This hides the warning everywhere, and cleans up the code a bit.
This commit is contained in:
parent
8ef4e4d452
commit
e5156df4f1
4 changed files with 95 additions and 173 deletions
|
|
@ -28,7 +28,7 @@ class ServerInfo {
|
||||||
|
|
||||||
const ServerInfo({
|
const ServerInfo({
|
||||||
required this.serverVersion,
|
required this.serverVersion,
|
||||||
required this.latestVersion,
|
this.latestVersion,
|
||||||
required this.serverFeatures,
|
required this.serverFeatures,
|
||||||
required this.serverConfig,
|
required this.serverConfig,
|
||||||
required this.serverDiskInfo,
|
required this.serverDiskInfo,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||||
: super(
|
: super(
|
||||||
const ServerInfo(
|
const ServerInfo(
|
||||||
serverVersion: ServerVersion(major: 0, minor: 0, patch: 0),
|
serverVersion: ServerVersion(major: 0, minor: 0, patch: 0),
|
||||||
latestVersion: null,
|
|
||||||
serverFeatures: ServerFeatures(map: true, trash: true, oauthEnabled: false, passwordLogin: true),
|
serverFeatures: ServerFeatures(map: true, trash: true, oauthEnabled: false, passwordLogin: true),
|
||||||
serverConfig: ServerConfig(
|
serverConfig: ServerConfig(
|
||||||
trashDays: 30,
|
trashDays: 30,
|
||||||
|
|
@ -104,7 +103,9 @@ final serverInfoProvider = StateNotifierProvider<ServerInfoNotifier, ServerInfo>
|
||||||
|
|
||||||
final versionWarningPresentProvider = Provider.family<bool, UserDto?>((ref, user) {
|
final versionWarningPresentProvider = Provider.family<bool, UserDto?>((ref, user) {
|
||||||
final serverInfo = ref.watch(serverInfoProvider);
|
final serverInfo = ref.watch(serverInfoProvider);
|
||||||
return serverInfo.versionStatus == VersionStatus.clientOutOfDate ||
|
return switch (serverInfo.versionStatus) {
|
||||||
serverInfo.versionStatus == VersionStatus.error ||
|
VersionStatus.clientOutOfDate || VersionStatus.error => true,
|
||||||
((user?.isAdmin ?? false) && serverInfo.versionStatus == VersionStatus.serverOutOfDate);
|
VersionStatus.serverOutOfDate => serverInfo.latestVersion != null && (user?.isAdmin ?? false),
|
||||||
|
VersionStatus.upToDate => false,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ class AppBarServerInfo extends HookConsumerWidget {
|
||||||
final bool showVersionWarning = ref.watch(versionWarningPresentProvider(user));
|
final bool showVersionWarning = ref.watch(versionWarningPresentProvider(user));
|
||||||
|
|
||||||
final appInfo = useState({});
|
final appInfo = useState({});
|
||||||
const titleFontSize = 12.0;
|
|
||||||
const contentFontSize = 11.0;
|
|
||||||
|
|
||||||
getPackageInfo() async {
|
getPackageInfo() async {
|
||||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
|
@ -37,176 +35,38 @@ class AppBarServerInfo extends HookConsumerWidget {
|
||||||
return null;
|
return null;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const divider = Divider(thickness: 1);
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (showVersionWarning) ...[
|
if (showVersionWarning) ...[const ServerUpdateNotification(), divider],
|
||||||
const Padding(padding: EdgeInsets.symmetric(horizontal: 8.0), child: ServerUpdateNotification()),
|
_ServerInfoItem(
|
||||||
const Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: Divider(thickness: 1)),
|
label: "server_info_box_app_version".tr(),
|
||||||
],
|
text: "${appInfo.value["version"]} build.${appInfo.value["buildNumber"]}",
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
|
||||||
child: Text(
|
|
||||||
"server_info_box_app_version".tr(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: titleFontSize,
|
|
||||||
color: context.textTheme.labelSmall?.color,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 0,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: Text(
|
|
||||||
"${appInfo.value["version"]} build.${appInfo.value["buildNumber"]}",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: contentFontSize,
|
|
||||||
color: context.colorScheme.onSurfaceSecondary,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: Divider(thickness: 1)),
|
divider,
|
||||||
Row(
|
_ServerInfoItem(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
label: "server_version".tr(),
|
||||||
children: [
|
text: serverInfoState.serverVersion.major > 0
|
||||||
Expanded(
|
? "${serverInfoState.serverVersion.major}.${serverInfoState.serverVersion.minor}.${serverInfoState.serverVersion.patch}"
|
||||||
child: Padding(
|
: "--",
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
|
||||||
child: Text(
|
|
||||||
"server_version".tr(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: titleFontSize,
|
|
||||||
color: context.textTheme.labelSmall?.color,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 0,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: Text(
|
|
||||||
serverInfoState.serverVersion.major > 0
|
|
||||||
? "${serverInfoState.serverVersion.major}.${serverInfoState.serverVersion.minor}.${serverInfoState.serverVersion.patch}"
|
|
||||||
: "--",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: contentFontSize,
|
|
||||||
color: context.colorScheme.onSurfaceSecondary,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: Divider(thickness: 1)),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
|
||||||
child: Text(
|
|
||||||
"server_info_box_server_url".tr(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: titleFontSize,
|
|
||||||
color: context.textTheme.labelSmall?.color,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 0,
|
|
||||||
child: Container(
|
|
||||||
width: 200,
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: Tooltip(
|
|
||||||
verticalOffset: 0,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: context.primaryColor.withValues(alpha: 0.9),
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
||||||
),
|
|
||||||
textStyle: TextStyle(
|
|
||||||
color: context.isDarkTheme ? Colors.black : Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
message: getServerUrl() ?? '--',
|
|
||||||
preferBelow: false,
|
|
||||||
triggerMode: TooltipTriggerMode.tap,
|
|
||||||
child: Text(
|
|
||||||
getServerUrl() ?? '--',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: contentFontSize,
|
|
||||||
color: context.colorScheme.onSurfaceSecondary,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
divider,
|
||||||
|
_ServerInfoItem(label: "server_info_box_server_url".tr(), text: getServerUrl() ?? '--', tooltip: true),
|
||||||
if (serverInfoState.latestVersion != null) ...[
|
if (serverInfoState.latestVersion != null) ...[
|
||||||
const Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: Divider(thickness: 1)),
|
divider,
|
||||||
Row(
|
_ServerInfoItem(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
label: "latest_version".tr(),
|
||||||
children: [
|
text: serverInfoState.latestVersion!.major > 0
|
||||||
Expanded(
|
? "${serverInfoState.latestVersion!.major}.${serverInfoState.latestVersion!.minor}.${serverInfoState.latestVersion!.patch}"
|
||||||
child: Padding(
|
: "--",
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
tooltip: true,
|
||||||
child: Row(
|
icon: serverInfoState.versionStatus == VersionStatus.serverOutOfDate
|
||||||
children: [
|
? const Icon(Icons.info, color: Color.fromARGB(255, 243, 188, 106), size: 12)
|
||||||
if (serverInfoState.versionStatus == VersionStatus.serverOutOfDate)
|
: null,
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.only(right: 5.0),
|
|
||||||
child: Icon(Icons.info, color: Color.fromARGB(255, 243, 188, 106), size: 12),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"latest_version".tr(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: titleFontSize,
|
|
||||||
color: context.textTheme.labelSmall?.color,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 0,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: Text(
|
|
||||||
serverInfoState.latestVersion!.major > 0
|
|
||||||
? "${serverInfoState.latestVersion!.major}.${serverInfoState.latestVersion!.minor}.${serverInfoState.latestVersion!.patch}"
|
|
||||||
: "--",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: contentFontSize,
|
|
||||||
color: context.colorScheme.onSurfaceSecondary,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
@ -214,3 +74,64 @@ class AppBarServerInfo extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ServerInfoItem extends StatelessWidget {
|
||||||
|
final String label;
|
||||||
|
final String text;
|
||||||
|
final bool tooltip;
|
||||||
|
final Icon? icon;
|
||||||
|
|
||||||
|
static const titleFontSize = 12.0;
|
||||||
|
static const contentFontSize = 11.0;
|
||||||
|
|
||||||
|
const _ServerInfoItem({required this.label, required this.text, this.tooltip = false, this.icon});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
if (icon != null) ...[icon as Widget, const SizedBox(width: 8)],
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: titleFontSize,
|
||||||
|
color: context.textTheme.labelSmall?.color,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: _maybeTooltip(
|
||||||
|
context,
|
||||||
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: contentFontSize,
|
||||||
|
color: context.colorScheme.onSurfaceSecondary,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _maybeTooltip(BuildContext context, Widget child) => tooltip
|
||||||
|
? Tooltip(
|
||||||
|
verticalOffset: 0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: context.primaryColor.withValues(alpha: 0.9),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
|
),
|
||||||
|
textStyle: TextStyle(color: context.colorScheme.onPrimary, fontWeight: FontWeight.bold),
|
||||||
|
message: text,
|
||||||
|
preferBelow: false,
|
||||||
|
triggerMode: TooltipTriggerMode.tap,
|
||||||
|
child: child,
|
||||||
|
)
|
||||||
|
: child;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1217,10 +1217,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.0"
|
version: "1.16.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -1910,10 +1910,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.7"
|
version: "0.7.6"
|
||||||
thumbhash:
|
thumbhash:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue