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
5 changes: 3 additions & 2 deletions lib/core/sdui/sdui_form_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ class SduiFormBuilderState extends material.State<SduiFormBuilder> {
final path =
picker != null ? await picker(field) : (await openFile())?.path;
if (path == null || !mounted) return;
_textControllers[field.id]?.text = path;
setState(() {
_textControllers[field.id]?.text = path;
});
_notifyChanged();
setState(() {});
}

@override
Expand Down
14 changes: 8 additions & 6 deletions lib/features/connections/new_folder_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class _NewFolderDialogContentState
child: TextField(
controller: _nameController,
placeholder: const Text('Folder name'),
onChanged: (_) => setState(() {}),
),
),
],
Expand All @@ -106,11 +105,14 @@ class _NewFolderDialogContentState
child: const Text('Cancel'),
),
const material.SizedBox(width: 12),
PrimaryButton(
onPressed: _name.isEmpty
? null
: () => material.Navigator.of(context).pop(_name),
child: const Text('Create'),
ListenableBuilder(
listenable: _nameController,
builder: (context, _) => PrimaryButton(
onPressed: _name.isEmpty
? null
: () => material.Navigator.of(context).pop(_name),
child: const Text('Create'),
),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/features/extensions/extension_stats_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class _ExtensionStatsViewState extends material.State<ExtensionStatsView> {
.getServerStats(widget.connectionRow);
if (!mounted) return;
if (!replaceIfChanged(_stats, stats, (v) => _stats = v)) return;
setState(() {});
setState(() => _stats = stats);
} catch (_) {}
}

Expand Down
18 changes: 6 additions & 12 deletions lib/features/mongodb/mongo_database_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ class _CreateMongoDBDialogContentState
extends material.State<_CreateMongoDBDialogContent> {
final _nameController = material.TextEditingController();

@override
void initState() {
super.initState();
_nameController.addListener(_onFieldChanged);
}

void _onFieldChanged() => setState(() {});

bool get _formValid => _nameController.text.trim().isNotEmpty;

void _save() {
Expand All @@ -43,7 +35,6 @@ class _CreateMongoDBDialogContentState

@override
void dispose() {
_nameController.removeListener(_onFieldChanged);
_nameController.dispose();
super.dispose();
}
Expand Down Expand Up @@ -106,9 +97,12 @@ class _CreateMongoDBDialogContentState
child: const Text('Cancel'),
),
const Gap(12),
PrimaryButton(
onPressed: _formValid ? _save : null,
child: const Text('Create'),
ListenableBuilder(
listenable: _nameController,
builder: (context, _) => PrimaryButton(
onPressed: _formValid ? _save : null,
child: const Text('Create'),
),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/features/mysql/mysql_stats_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class _MysqlStatsViewState extends material.State<MysqlStatsView> {
final stats = await conn.serverStats();
if (!mounted) return;
if (!replaceIfChanged(_stats, stats, (v) => _stats = v)) return;
setState(() {});
setState(() => _stats = stats);
} catch (_) {}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/features/postgresql/postgres_stats_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class _PostgresStatsViewState extends material.State<PostgresStatsView> {
final stats = await c.serverStats();
if (!mounted) return;
if (!replaceIfChanged(_stats, stats, (v) => _stats = v)) return;
setState(() {});
setState(() => _stats = stats);
} catch (_) {}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/features/redis/redis_explorer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _RedisExplorerViewState extends material.State<RedisExplorerView> {

// View mode
bool _showStats = false;
int _refreshEpoch = 0;

// Navigation state
String? _selectedKey;
Expand Down Expand Up @@ -224,7 +225,7 @@ class _RedisExplorerViewState extends material.State<RedisExplorerView> {
_BreadcrumbBar(
crumbs: _crumbs,
onCrumbTap: _onCrumbTap,
onRefresh: () => setState(() {}),
onRefresh: () => setState(() => _refreshEpoch++),
onStats: () => setState(() => _showStats = true),
),
const Divider(height: 1),
Expand All @@ -238,7 +239,7 @@ class _RedisExplorerViewState extends material.State<RedisExplorerView> {
// Key editor
if (_selectedKey != null) {
return RedisKeyEditor(
key: ValueKey('key_${widget.database}_$_selectedKey'),
key: ValueKey('key_${widget.database}_${_selectedKey}_$_refreshEpoch'),
connection: conn,
database: widget.database,
keyName: _selectedKey!,
Expand All @@ -250,7 +251,7 @@ class _RedisExplorerViewState extends material.State<RedisExplorerView> {

// Keys list
return RedisKeysView(
key: ValueKey('keys_${widget.database}'),
key: ValueKey('keys_${widget.database}_$_refreshEpoch'),
connection: conn,
database: widget.database,
onKeyTap: _navigateToKey,
Expand Down
2 changes: 1 addition & 1 deletion lib/features/redis/redis_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class _RedisViewState extends material.State<RedisView> {
final info = parseRedisInfo(raw);
if (!mounted) return;
if (!replaceIfChanged(_info, info, (v) => _info = v)) return;
setState(() {});
setState(() => _info = info);
} catch (_) {}
}

Expand Down
27 changes: 8 additions & 19 deletions lib/features/settings/preferences_appearance_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ class _PreferencesAppearanceSectionState
bool _installingFromUrl = false;
bool _openingThemesFolder = false;

@override
void initState() {
super.initState();
_controller.addListener(_onThemeChanged);
}

@override
void dispose() {
_controller.removeListener(_onThemeChanged);
super.dispose();
}

void _onThemeChanged() {
if (mounted) setState(() {});
}

Future<void> _setThemeMode(ThemeMode mode) async {
await _controller.setThemeMode(mode);
}
Expand Down Expand Up @@ -160,9 +144,12 @@ class _PreferencesAppearanceSectionState

@override
material.Widget build(material.BuildContext context) {
final c = _controller;
final themes = c.availableThemes;
final refreshingThemes = c.isLoadingAvailableThemes;
return ListenableBuilder(
listenable: _controller,
builder: (context, _) {
final c = _controller;
final themes = c.availableThemes;
final refreshingThemes = c.isLoadingAvailableThemes;

return material.Column(
crossAxisAlignment: material.CrossAxisAlignment.start,
Expand Down Expand Up @@ -364,5 +351,7 @@ class _PreferencesAppearanceSectionState
),
],
);
},
);
}
}
4 changes: 3 additions & 1 deletion lib/features/settings/preferences_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ class _InterfaceScaleSliderState extends material.State<InterfaceScaleSlider> {

void _onCommittedScaleChanged() {
if (_dragScale != null || !mounted) return;
setState(() {});
setState(() {
_dragScale = null;
});
}

bool _onKeyEvent(KeyEvent event) {
Expand Down
8 changes: 6 additions & 2 deletions lib/features/settings/theme_picker_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ class _ThemePickerButtonState extends material.State<ThemePickerButton> {
});
}

String _searchQuery = '';

void _onSearchChanged() {
setState(() {});
setState(() {
_searchQuery = _searchController.text;
});
if (_scrollController.hasClients) {
_scrollController.jumpTo(0);
}
Expand All @@ -187,7 +191,7 @@ class _ThemePickerButtonState extends material.State<ThemePickerButton> {
}

List<ThemeDefinition> get _filteredThemes =>
filterThemeDefinitions(widget.themes, _searchController.text);
filterThemeDefinitions(widget.themes, _searchQuery);

bool get _enabled => !widget.isLoading;

Expand Down
12 changes: 8 additions & 4 deletions lib/features/updater/update_available_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class UpdateAvailableBadgeState extends material.State<UpdateAvailableBadge>

void _onControllerChanged() {
if (!mounted) return;
setState(() {});
_syncPulse();
}

Expand Down Expand Up @@ -100,9 +99,12 @@ class UpdateAvailableBadgeState extends material.State<UpdateAvailableBadge>

@override
material.Widget build(material.BuildContext context) {
if (!widget.controller.showBadge) {
return const material.SizedBox.shrink();
}
return ListenableBuilder(
listenable: widget.controller,
builder: (context, _) {
if (!widget.controller.showBadge) {
return const material.SizedBox.shrink();
}

final version = widget.controller.pendingUpdate?.version ?? '';
final wb = context.workbench;
Expand Down Expand Up @@ -160,5 +162,7 @@ class UpdateAvailableBadgeState extends material.State<UpdateAvailableBadge>
),
),
);
},
);
}
}
76 changes: 22 additions & 54 deletions lib/shared/widgets/querya_tab_strip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class _QueryaTabStripState extends material.State<QueryaTabStrip>
}

/// Sliding pill; listens to springs so the tab [Row] is not rebuilt per tick.
class _TabStripIndicator extends material.StatefulWidget {
class _TabStripIndicator extends material.StatelessWidget {
const _TabStripIndicator({
required this.left,
required this.width,
Expand All @@ -262,63 +262,31 @@ class _TabStripIndicator extends material.StatefulWidget {
final QueryaSpringController width;
final material.Color color;

@override
material.State<_TabStripIndicator> createState() =>
_TabStripIndicatorState();
}

class _TabStripIndicatorState extends material.State<_TabStripIndicator> {
@override
void initState() {
super.initState();
widget.left.addListener(_onTick);
widget.width.addListener(_onTick);
}

@override
void didUpdateWidget(covariant _TabStripIndicator oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.left != widget.left) {
oldWidget.left.removeListener(_onTick);
widget.left.addListener(_onTick);
}
if (oldWidget.width != widget.width) {
oldWidget.width.removeListener(_onTick);
widget.width.addListener(_onTick);
}
}

@override
void dispose() {
widget.left.removeListener(_onTick);
widget.width.removeListener(_onTick);
super.dispose();
}

void _onTick() {
if (mounted) setState(() {});
}

@override
material.Widget build(material.BuildContext context) {
final w = widget.width.value;
if (w <= 0) return const material.SizedBox.shrink();
return material.Positioned(
key: const material.ValueKey('querya_tab_indicator'),
left: widget.left.value,
width: w,
top: 0,
bottom: 0,
child: material.RepaintBoundary(
child: material.IgnorePointer(
child: material.DecoratedBox(
decoration: material.BoxDecoration(
color: widget.color,
borderRadius: material.BorderRadius.circular(6),
return ListenableBuilder(
listenable: Listenable.merge([left, width]),
builder: (context, _) {
final w = width.value;
if (w <= 0) return const material.SizedBox.shrink();
return material.Positioned(
key: const material.ValueKey('querya_tab_indicator'),
left: left.value,
width: w,
top: 0,
bottom: 0,
child: material.RepaintBoundary(
child: material.IgnorePointer(
child: material.DecoratedBox(
decoration: material.BoxDecoration(
color: color,
borderRadius: material.BorderRadius.circular(6),
),
),
),
),
),
),
);
},
);
}
}
Expand Down
Loading