fix: Config viewer not updating state
This commit is contained in:
parent
15d42a1fbd
commit
1991707be7
3 changed files with 39 additions and 42 deletions
|
|
@ -289,6 +289,7 @@ class ChatInputRow extends StatelessWidget {
|
||||||
bottom: 6.0,
|
bottom: 6.0,
|
||||||
top: 3.0,
|
top: 3.0,
|
||||||
),
|
),
|
||||||
|
counter: const SizedBox.shrink(),
|
||||||
hintText: L10n.of(context).writeAMessage,
|
hintText: L10n.of(context).writeAMessage,
|
||||||
hintMaxLines: 1,
|
hintMaxLines: 1,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class InputBar extends StatelessWidget {
|
||||||
final ValueChanged<Uint8List?>? onSubmitImage;
|
final ValueChanged<Uint8List?>? onSubmitImage;
|
||||||
final FocusNode? focusNode;
|
final FocusNode? focusNode;
|
||||||
final TextEditingController? controller;
|
final TextEditingController? controller;
|
||||||
final InputDecoration? decoration;
|
final InputDecoration decoration;
|
||||||
final ValueChanged<String>? onChanged;
|
final ValueChanged<String>? onChanged;
|
||||||
final bool? autofocus;
|
final bool? autofocus;
|
||||||
final bool readOnly;
|
final bool readOnly;
|
||||||
|
|
@ -37,7 +37,7 @@ class InputBar extends StatelessWidget {
|
||||||
this.onSubmitImage,
|
this.onSubmitImage,
|
||||||
this.focusNode,
|
this.focusNode,
|
||||||
this.controller,
|
this.controller,
|
||||||
this.decoration,
|
required this.decoration,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.autofocus,
|
this.autofocus,
|
||||||
this.textInputAction,
|
this.textInputAction,
|
||||||
|
|
@ -437,7 +437,8 @@ class InputBar extends StatelessWidget {
|
||||||
// it sets the types for the callback incorrectly
|
// it sets the types for the callback incorrectly
|
||||||
onSubmitted!(text);
|
onSubmitted!(text);
|
||||||
},
|
},
|
||||||
decoration: decoration!,
|
maxLength: 16384,
|
||||||
|
decoration: decoration,
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
// fix for the library for now
|
// fix for the library for now
|
||||||
// it sets the types for the callback incorrectly
|
// it sets the types for the callback incorrectly
|
||||||
|
|
@ -445,6 +446,7 @@ class InputBar extends StatelessWidget {
|
||||||
},
|
},
|
||||||
textCapitalization: TextCapitalization.sentences,
|
textCapitalization: TextCapitalization.sentences,
|
||||||
),
|
),
|
||||||
|
|
||||||
suggestionsCallback: getSuggestions,
|
suggestionsCallback: getSuggestions,
|
||||||
itemBuilder: (c, s) => buildSuggestion(c, s, Matrix.of(context).client),
|
itemBuilder: (c, s) => buildSuggestion(c, s, Matrix.of(context).client),
|
||||||
onSelected: (Map<String, String?> suggestion) =>
|
onSelected: (Map<String, String?> suggestion) =>
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,22 @@ import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
|
|
||||||
class ConfigViewer extends StatelessWidget {
|
class ConfigViewer extends StatefulWidget {
|
||||||
const ConfigViewer({super.key});
|
const ConfigViewer({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ConfigViewer> createState() => _ConfigViewerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ConfigViewerState extends State<ConfigViewer> {
|
||||||
void _changeSetting(
|
void _changeSetting(
|
||||||
BuildContext context,
|
|
||||||
AppSettings appSetting,
|
AppSettings appSetting,
|
||||||
SharedPreferences store,
|
SharedPreferences store,
|
||||||
Function setState,
|
|
||||||
String initialValue,
|
String initialValue,
|
||||||
) async {
|
) async {
|
||||||
if (appSetting is AppSettings<bool>) {
|
if (appSetting is AppSettings<bool>) {
|
||||||
appSetting.setItem(store, !(initialValue == 'true'));
|
await appSetting.setItem(store, !(initialValue == 'true'));
|
||||||
|
setState(() {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,13 +35,13 @@ class ConfigViewer extends StatelessWidget {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
|
|
||||||
if (appSetting is AppSettings<String>) {
|
if (appSetting is AppSettings<String>) {
|
||||||
appSetting.setItem(store, value);
|
await appSetting.setItem(store, value);
|
||||||
}
|
}
|
||||||
if (appSetting is AppSettings<int>) {
|
if (appSetting is AppSettings<int>) {
|
||||||
appSetting.setItem(store, int.parse(value));
|
await appSetting.setItem(store, int.parse(value));
|
||||||
}
|
}
|
||||||
if (appSetting is AppSettings<double>) {
|
if (appSetting is AppSettings<double>) {
|
||||||
appSetting.setItem(store, double.parse(value));
|
await appSetting.setItem(store, double.parse(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
@ -67,38 +71,28 @@ class ConfigViewer extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: StatefulBuilder(
|
child: ListView.builder(
|
||||||
builder: (context, setState) {
|
itemCount: AppSettings.values.length,
|
||||||
return ListView.builder(
|
itemBuilder: (context, i) {
|
||||||
itemCount: AppSettings.values.length,
|
final store = Matrix.of(context).store;
|
||||||
itemBuilder: (context, i) {
|
final appSetting = AppSettings.values[i];
|
||||||
final store = Matrix.of(context).store;
|
var value = '';
|
||||||
final appSetting = AppSettings.values[i];
|
if (appSetting is AppSettings<String>) {
|
||||||
var value = '';
|
value = appSetting.getItem(store);
|
||||||
if (appSetting is AppSettings<String>) {
|
}
|
||||||
value = appSetting.getItem(store);
|
if (appSetting is AppSettings<int>) {
|
||||||
}
|
value = appSetting.getItem(store).toString();
|
||||||
if (appSetting is AppSettings<int>) {
|
}
|
||||||
value = appSetting.getItem(store).toString();
|
if (appSetting is AppSettings<bool>) {
|
||||||
}
|
value = appSetting.getItem(store).toString();
|
||||||
if (appSetting is AppSettings<bool>) {
|
}
|
||||||
value = appSetting.getItem(store).toString();
|
if (appSetting is AppSettings<double>) {
|
||||||
}
|
value = appSetting.getItem(store).toString();
|
||||||
if (appSetting is AppSettings<double>) {
|
}
|
||||||
value = appSetting.getItem(store).toString();
|
return ListTile(
|
||||||
}
|
title: Text(appSetting.name),
|
||||||
return ListTile(
|
subtitle: Text(value),
|
||||||
title: Text(appSetting.name),
|
onTap: () => _changeSetting(appSetting, store, value),
|
||||||
subtitle: Text(value),
|
|
||||||
onTap: () => _changeSetting(
|
|
||||||
context,
|
|
||||||
appSetting,
|
|
||||||
store,
|
|
||||||
setState,
|
|
||||||
value,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue