Skip to content

Commit b4fe761

Browse files
authored
Merge pull request #30 from getditto/cx-538-system-config
CX-538: Flutter Tools - System Configuration
2 parents 9812e43 + b6b5425 commit b4fe761

File tree

5 files changed

+363
-11
lines changed

5 files changed

+363
-11
lines changed

CLAUDE.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,18 @@ Repository: https://github.com/getditto/ditto_flutter_tools
136136
- the claude\designs directory is used for all design related files and should not be used for any other purpose.
137137

138138
# Code Style
139-
- Always recommend dart code vs trying to use native code in Swift or Kotlin, etc. If required, look for 3rd party libraries that might be available that publish solutions that work in all platforms (mac, linux, windows, android, ios, web).
139+
- Always recommend dart code vs trying to use native code in Swift or Kotlin, etc. If required, look for 3rd party libraries that might be available that publish solutions that work in all platforms (mac, linux, windows, android, ios, web).
140+
141+
- If you're rendering a list of items, use ListView even if you only have one string you want to display: ListView(title: Text(string))
142+
- If you have multiple, use subtitle as well
143+
- If you need the option for lots of text, use ExpansionTile
144+
- NO hardcoding theme stuff, since Flutter users expect to be able to override these values via Theme
145+
146+
- In general, pulling larger chunks of UI out into getters really helps readability, e.g.
147+
148+
class MyState extends State<MyWidget> {
149+
// ...
150+
151+
Widget get something => ListTile(/* ... */ );
152+
}
153+
Flutter has an insane problem with rightward drift, and this is one of the few tools we have to combat it

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,71 @@ Both export features now use the **native platform Share API** for a seamless us
112112
- The `share_plus` package handles all platform-specific sharing requirements automatically
113113
- Users can share to any compatible app (email, cloud storage, messaging, etc.) through the native platform dialogs
114114

115+
## `SystemSettingsView`
116+
117+
The `SystemSettingsView` provides a comprehensive interface for viewing and inspecting all Ditto system configuration settings. This diagnostic tool helps developers understand the current runtime configuration of their Ditto instance by displaying all system parameters retrieved using the `SHOW ALL` DQL statement.
118+
119+
### Usage
120+
121+
The `SystemSettingsView` can be used as a standalone widget in your Flutter application:
122+
123+
```dart
124+
import 'package:ditto_flutter_tools/ditto_flutter_tools.dart';
125+
126+
// In your widget build method
127+
Scaffold(
128+
appBar: AppBar(title: Text('System Settings')),
129+
body: SystemSettingsView(ditto: myDittoInstance),
130+
)
131+
```
132+
133+
### Features
134+
135+
The system settings view provides:
136+
137+
1. **Dynamic Settings Display** - Automatically displays all available system settings without hardcoded keys, adapting to different Ditto SDK versions
138+
2. **Search Functionality** - Real-time search/filter to quickly find specific settings by key or value
139+
3. **Smart Value Formatting** - Intelligent display of different data types (boolean, number, string, array, object)
140+
4. **Detailed View** - Expandable detail dialog for complex values (arrays, objects, long strings)
141+
5. **Copy to Clipboard** - Easy copying of setting key-value pairs for debugging or documentation
142+
6. **Live Refresh** - Manual refresh button to reload settings and see configuration changes
143+
144+
### Settings Information Displayed
145+
146+
The view displays all system configuration parameters including but not limited to:
147+
- **Replication Settings** - Parameters controlling data synchronization behavior
148+
- **Network Settings** - Configuration for mesh networking, routing, and transports
149+
- **Storage Settings** - Database and blob store configuration
150+
- **Performance Settings** - Timeout values, batch sizes, and optimization parameters
151+
- **Feature Flags** - Enabled/disabled features and experimental options
152+
153+
### Value Visualization
154+
155+
Different data types are displayed with appropriate formatting:
156+
- **Booleans** - Color-coded badges (green for true, grey for false)
157+
- **Numbers** - Monospace font for easy reading
158+
- **Strings** - Truncated with full view on tap for long values
159+
- **Arrays/Objects** - Compact badge showing type and item count, expandable for full JSON view
160+
- **Empty Values** - Clear indication of empty arrays, objects, or strings
161+
162+
### Real-time Search
163+
164+
The search feature allows filtering by:
165+
- Setting key names (e.g., searching for "replication" shows all replication-related settings)
166+
- Setting values (e.g., searching for "true" shows all boolean settings that are enabled)
167+
- Case-insensitive matching for convenience
168+
169+
### Platform Support
170+
-**iOS**: Full support
171+
-**Android**: Full support
172+
-**macOS**: Full support
173+
-**Linux**: Full support
174+
-**Web**: Full support (when Ditto Web SDK supports DQL execution)
175+
176+
### Documentation Reference
177+
178+
For more information about system settings and the `SHOW ALL` DQL statement, see the [Ditto documentation on retrieving system values](https://docs.ditto.live/sdk/latest/sync/using-alter-system#retrieving-values).
179+
115180
## `SyncStatusHelper` and `SyncStatusView`
116181

117182
These tools are intended to provide insights into the status of your subscriptions.

example/lib/main.dart

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,7 @@ class _MainListView extends StatelessWidget {
287287
);
288288
},
289289
),
290-
Divider(
291-
height: 1,
292-
color:
293-
Theme.of(context).colorScheme.outline.withOpacity(0.3),
294-
indent: 56),
290+
const Divider(),
295291
ListTile(
296292
leading: Container(
297293
width: 32,
@@ -410,11 +406,7 @@ class _MainListView extends StatelessWidget {
410406
);
411407
},
412408
),
413-
Divider(
414-
height: 1,
415-
color:
416-
Theme.of(context).colorScheme.outline.withOpacity(0.3),
417-
indent: 56),
409+
const Divider(),
418410
ListTile(
419411
leading: Container(
420412
width: 32,
@@ -456,6 +448,50 @@ class _MainListView extends StatelessWidget {
456448
);
457449
},
458450
),
451+
const Divider(),
452+
ListTile(
453+
leading: Container(
454+
width: 32,
455+
height: 32,
456+
decoration: BoxDecoration(
457+
color: Colors.orange,
458+
borderRadius: BorderRadius.circular(8),
459+
),
460+
child: const Icon(
461+
Icons.settings,
462+
color: Colors.white,
463+
size: 20,
464+
),
465+
),
466+
title: const Text("System Settings"),
467+
trailing: Icon(Icons.chevron_right,
468+
color: Theme.of(context).colorScheme.onSurfaceVariant),
469+
onTap: () {
470+
Navigator.of(context).push(
471+
PageRouteBuilder(
472+
pageBuilder: (context, animation, secondaryAnimation) =>
473+
Material(
474+
child: Scaffold(
475+
appBar:
476+
AppBar(title: const Text("System Settings")),
477+
body:
478+
SystemSettingsView(ditto: dittoService.ditto!),
479+
),
480+
),
481+
transitionsBuilder:
482+
(context, animation, secondaryAnimation, child) {
483+
return SlideTransition(
484+
position: Tween<Offset>(
485+
begin: const Offset(1.0, 0.0),
486+
end: Offset.zero,
487+
).animate(animation),
488+
child: child,
489+
);
490+
},
491+
),
492+
);
493+
},
494+
),
459495
],
460496
),
461497
),

lib/ditto_flutter_tools.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export "src/permissions_health/wifi_permissions_cross_platform.dart"
1313
export "src/sync_status_view.dart" show SyncStatusView;
1414
export "src/sync_status_helper.dart" show SyncStatusHelper, SyncStatus;
1515
export "src/peer_list.dart" show PeerListView;
16+
export "src/system_settings_view.dart" show SystemSettingsView;

0 commit comments

Comments
 (0)