Files
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

109 lines
3.9 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../settings/settings_operation.dart';
import '../../integrations/app_updates.dart';
import 'update_controller.dart';
import '../../l10n/l10n.dart';
import 'package:cutdex_ui/widgets.dart';
class UpdateSettings extends ConsumerWidget {
const UpdateSettings({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
if (!supportsAppUpdates) {
return const SizedBox.shrink();
}
final status = ref.watch(updateControllerProvider).value;
final operation = ref.watch(settingsOperationProvider('updates'));
final controller = ref.read(updateControllerProvider.notifier);
final configured = status?.configured == true;
final version = status?.version ?? '';
final build = status?.build ?? '';
final windows = defaultTargetPlatform == TargetPlatform.windows;
final busy =
operation.isLoading ||
const [
UpdatePhase.checking,
UpdatePhase.downloading,
UpdatePhase.installing,
].contains(status?.phase);
return AppField(
label: context.l10n.softwareUpdates,
orientation: AppFieldOrientation.horizontal,
error: operation.hasError || status?.error.isNotEmpty == true
? (windows
? context.l10n.updateOperationFailed
: context.l10n.updateCheckFailed)
: null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Wrap(
alignment: WrapAlignment.end,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 12,
children: [
if (version.isNotEmpty) Text('$version ($build)'),
OutlinedButton(
key: const Key('check-for-updates'),
onPressed:
configured &&
!busy &&
(!windows || status?.canCheck == true)
? controller.check
: null,
child: Text(context.l10n.checkForUpdates),
),
],
),
if (windows && status?.phase == UpdatePhase.checking)
Text(context.l10n.checkingForUpdates),
if (windows && status?.phase == UpdatePhase.current)
Text(context.l10n.appIsUpToDate),
if (windows && status?.phase == UpdatePhase.downloading) ...[
Text(context.l10n.downloadingUpdate(status!.progress)),
SizedBox(
width: 200,
child: LinearProgressIndicator(value: status.progress / 100),
),
],
if (windows && status?.availableVersion.isNotEmpty == true) ...[
Text(context.l10n.updateAvailable(status!.availableVersion)),
if (status.phase == UpdatePhase.available)
OutlinedButton(
key: const Key('download-update'),
onPressed: busy ? null : controller.download,
child: Text(context.l10n.downloadUpdate),
),
if (status.phase == UpdatePhase.ready)
OutlinedButton(
key: const Key('install-update'),
onPressed: busy ? null : controller.install,
child: Text(context.l10n.restartToUpdate),
),
],
if (configured)
Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(context.l10n.automaticallyCheckUpdates)),
AppSwitch(
semanticLabel: context.l10n.automaticallyCheckUpdates,
value: status!.automaticChecks,
onChanged: busy ? null : controller.setAutomaticChecks,
),
],
)
else if (status != null)
Text(context.l10n.updatesUnavailable),
],
),
);
}
}