Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ class _ThemeProvider extends StatefulWidget {
}

class _ThemeProviderState extends State<_ThemeProvider> {
@override
void initState() {
super.initState();
// Load settings
Provider.of<Settings>(context, listen: false).loadSettings();
}

@override
Widget build(BuildContext context) {
final display = context
Expand Down Expand Up @@ -279,38 +272,45 @@ class _MainWindowState extends State<MainWindow> with WindowListener, Loggable {
@override
void didChangeDependencies() {
super.didChangeDependencies();
final nextDownloadDataService = Provider.of<DownloadDataService>(
context,
listen: false,
_downloadDataService = _swapListener(
Provider.of<DownloadDataService>(context, listen: false),
_downloadDataService,
(l) => l?.removeListener(_handleDownloadNotifications),
(l) => l?.addListener(_handleDownloadNotifications),
);
if (_downloadDataService != nextDownloadDataService) {
_downloadDataService?.removeListener(_handleDownloadNotifications);
_downloadDataService = nextDownloadDataService;
_downloadDataService?.addListener(_handleDownloadNotifications);
}

final nextInstanceManager = Provider.of<InstanceManager>(
context,
listen: false,
_instanceManager = _swapListener(
Provider.of<InstanceManager>(context, listen: false),
_instanceManager,
(l) => l?.removeListener(_handleInstanceManagerChanged),
(l) => l?.addListener(_handleInstanceManagerChanged),
);
if (_instanceManager != nextInstanceManager) {
_instanceManager?.removeListener(_handleInstanceManagerChanged);
_instanceManager = nextInstanceManager;
_instanceManager?.addListener(_handleInstanceManagerChanged);
}

final nextSettings = Provider.of<Settings>(context, listen: false);
if (_settings != nextSettings) {
_settings?.removeListener(_handleSettingsChanged);
_settings = nextSettings;
_settings?.addListener(_handleSettingsChanged);
}
_settings = _swapListener(
Provider.of<Settings>(context, listen: false),
_settings,
(l) => l?.removeListener(_handleSettingsChanged),
(l) => l?.addListener(_handleSettingsChanged),
);

WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(_applyShellSettings());
});
}

T _swapListener<T>(
T next,
T? current,
void Function(T? l) remove,
void Function(T l) add,
) {
if (current != next) {
remove(current);
add(next);
}
return next;
}

void _handleSettingsChanged() {
unawaited(_handleTrayStateChanged());
unawaited(_applyShellSettings());
Expand Down
20 changes: 10 additions & 10 deletions lib/kit/provider/debug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class DebugProvider {
lines.add('$title$level$message');

var widgetCount = 1;
widgets.value.add(
final newWidgets = <Widget>[
Text.rich(
TextSpan(
children: [
Expand All @@ -47,10 +47,10 @@ final class DebugProvider {
],
),
),
);
];
if (record.stackTrace != null) {
widgetCount++;
widgets.value.add(
newWidgets.add(
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(
Expand All @@ -61,24 +61,24 @@ final class DebugProvider {
);
}
widgetCount++;
widgets.value.add(UIs.height13);
newWidgets.add(UIs.height13);
_widgetCounts.add(widgetCount);

while (lines.length > maxLines) {
final removed = _widgetCounts.removeAt(0);
final removeCount = _widgetCounts.removeAt(0);
lines.removeAt(0);
if (widgets.value.length >= removed) {
widgets.value.removeRange(0, removed);
if (widgets.value.length >= removeCount) {
widgets.value = widgets.value.sublist(removeCount);
}
}
widgets.notify();

widgets.value = [...widgets.value, ...newWidgets];
}

static void clear() {
widgets.value.clear();
widgets.value = [];
lines.clear();
_widgetCounts.clear();
widgets.notify();
}

static void copy() =>
Expand Down
1 change: 0 additions & 1 deletion lib/kit/widgets/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
Widget build(BuildContext context) {
return AppBar(
key: key,
title: title,
actions: actions,
centerTitle: centerTitle,
Expand Down
1 change: 0 additions & 1 deletion lib/kit/widgets/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class CardX extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
key: key,
clipBehavior: clipBehavior,
color: color,
shape: RoundedRectangleBorder(borderRadius: radius ?? borderRadius),
Expand Down
8 changes: 8 additions & 0 deletions lib/kit/widgets/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class Input extends StatefulWidget {
class _InputState extends State<Input> {
late bool _obscureText = widget.obscureText;

@override
void didUpdateWidget(covariant Input oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.obscureText != oldWidget.obscureText) {
_obscureText = widget.obscureText;
}
}

@override
Widget build(BuildContext context) {
final icon = widget.icon != null
Expand Down
21 changes: 11 additions & 10 deletions lib/kit/widgets/virtual_window_frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ class VirtualWindowFrame extends StatelessWidget {

@override
Widget build(BuildContext context) {
final content = switch (CustomAppBar.sysStatusBarHeight) {
0.0 => child,
_ when showCaption && WindowFrameConfig.showCaption => Column(
children: [
_WindowCaption(title: title),
Expanded(child: child),
],
),
_ => child,
};
final content =
(CustomAppBar.sysStatusBarHeight != 0.0 &&
showCaption &&
WindowFrameConfig.showCaption)
? Column(
children: [
_WindowCaption(title: title),
Expanded(child: child),
],
)
: child;
return wm.VirtualWindowFrame(child: content);
}
}
Expand Down
9 changes: 2 additions & 7 deletions lib/models/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ class Settings extends ChangeNotifier with Loggable {
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'; // User agent

// Settings file name
final String _settingsFileName = 'settings.json';
static const String _settingsFileName = 'settings.json';

// Constructor initialization
Settings();

/// Get program data directory
Directory _getDataDirectory() {
return getAppDataDirectory();
}

Future<String> _defaultDownloadDirectory() {
return Future.value(getDefaultDownloadDirectorySync());
}
Expand Down Expand Up @@ -165,7 +160,7 @@ class Settings extends ChangeNotifier with Loggable {

/// Get settings file path
String _getSettingsFilePath() {
final dataDir = _getDataDirectory();
final dataDir = getAppDataDirectory();
final configDir = Directory(p.join(dataDir.path, 'config'));
if (!configDir.existsSync()) {
configDir.createSync(recursive: true);
Expand Down
25 changes: 13 additions & 12 deletions lib/pages/download_page/components/add_task_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -559,18 +559,6 @@ class _AddTaskDialogState extends State<AddTaskDialog>
return LayoutBuilder(
builder: (context, constraints) {
final useTwoColumns = constraints.maxWidth >= 480;
final splitField = _buildSplitStepper(l10n);
final outputField = Expanded(
flex: 3,
child: TextField(
controller: outputFileNameController,
enabled: !_isSubmitting,
decoration: InputDecoration(
labelText: l10n.renameOutput,
hintText: l10n.renameOutputPlaceholder,
),
),
);

if (!useTwoColumns) {
return Column(
Expand All @@ -589,6 +577,19 @@ class _AddTaskDialogState extends State<AddTaskDialog>
);
}

final splitField = _buildSplitStepper(l10n);
final outputField = Expanded(
flex: 3,
child: TextField(
controller: outputFileNameController,
enabled: !_isSubmitting,
decoration: InputDecoration(
labelText: l10n.renameOutput,
hintText: l10n.renameOutputPlaceholder,
),
),
);

return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [outputField, const SizedBox(width: 12), splitField],
Expand Down
6 changes: 1 addition & 5 deletions lib/pages/download_page/components/filter_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FilterSelector extends StatelessWidget {
borderRadius: BorderRadius.circular(20),
),
),
..._getInstanceFilterOptions().map((instanceId) {
...instanceIds.map((instanceId) {
final isSelected = selectedInstanceId == instanceId;
final instanceColor = colorScheme.tertiary;
final instanceName =
Expand Down Expand Up @@ -220,10 +220,6 @@ class FilterSelector extends StatelessWidget {
}
}

List<String> _getInstanceFilterOptions() {
return instanceIds;
}

List<FilterOption> _getFilterOptionsForCurrentCategory() {
switch (currentCategoryType) {
case CategoryType.byStatus:
Expand Down
Loading