Rename autocomplete setting (#143)
This commit is contained in:
parent
15ae9b137e
commit
ef75be5945
4 changed files with 65 additions and 68 deletions
|
|
@ -14,75 +14,71 @@ class ChatBottomBar extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Observer(
|
||||
builder: (context) {
|
||||
final emotes = [
|
||||
final matchingEmotes = [
|
||||
...chatStore.assetsStore.userEmoteToObject.values,
|
||||
...chatStore.assetsStore.bttvEmotes,
|
||||
...chatStore.assetsStore.ffzEmotes,
|
||||
...chatStore.assetsStore.sevenTVEmotes
|
||||
].where((emote) => emote.name.toLowerCase().contains(chatStore.textController.text.split(' ').last.toLowerCase())).toList();
|
||||
|
||||
final filteredMentionedChatters = chatStore.chatDetailsStore.allChatters
|
||||
final matchingChatters = chatStore.chatDetailsStore.allChatters
|
||||
.where((chatter) => chatter.contains(chatStore.textController.text.split(' ').last.replaceFirst('@', '').toLowerCase()))
|
||||
.toList();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
if (chatStore.settings.emoteAutocomplete && chatStore.showEmoteAutocomplete && emotes.isNotEmpty) ...[
|
||||
if (chatStore.settings.autocomplete && (chatStore.showEmoteAutocomplete || chatStore.showMentionAutocomplete)) ...[
|
||||
const Divider(
|
||||
height: 1.0,
|
||||
thickness: 1.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
itemCount: emotes.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) => InkWell(
|
||||
onTap: () => chatStore.addEmote(emotes[index], autocompleteMode: true),
|
||||
child: Tooltip(
|
||||
message: emotes[index].name,
|
||||
preferBelow: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
child: Center(
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: emotes[index].url,
|
||||
fadeInDuration: const Duration(),
|
||||
height: emotes[index].height?.toDouble() ?? defaultEmoteSize,
|
||||
width: emotes[index].width?.toDouble(),
|
||||
if (chatStore.showEmoteAutocomplete && matchingEmotes.isNotEmpty)
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
itemCount: matchingEmotes.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) => InkWell(
|
||||
onTap: () => chatStore.addEmote(matchingEmotes[index], autocompleteMode: true),
|
||||
child: Tooltip(
|
||||
message: matchingEmotes[index].name,
|
||||
preferBelow: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
child: Center(
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: matchingEmotes[index].url,
|
||||
fadeInDuration: const Duration(),
|
||||
height: matchingEmotes[index].height?.toDouble() ?? defaultEmoteSize,
|
||||
width: matchingEmotes[index].width?.toDouble(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
if (chatStore.showMentionAutocomplete && filteredMentionedChatters.isNotEmpty) ...[
|
||||
const Divider(
|
||||
height: 1.0,
|
||||
thickness: 1.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
itemCount: filteredMentionedChatters.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) => TextButton(
|
||||
onPressed: () {
|
||||
final split = chatStore.textController.text.split(' ')
|
||||
..removeLast()
|
||||
..add('@${filteredMentionedChatters[index]} ');
|
||||
if (chatStore.showMentionAutocomplete && matchingChatters.isNotEmpty)
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
itemCount: matchingChatters.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) => TextButton(
|
||||
onPressed: () {
|
||||
final split = chatStore.textController.text.split(' ')
|
||||
..removeLast()
|
||||
..add('@${matchingChatters[index]} ');
|
||||
|
||||
chatStore.textController.text = split.join(' ');
|
||||
chatStore.textController.selection = TextSelection.fromPosition(TextPosition(offset: chatStore.textController.text.length));
|
||||
},
|
||||
child: Text(filteredMentionedChatters[index]),
|
||||
chatStore.textController.text = split.join(' ');
|
||||
chatStore.textController.selection = TextSelection.fromPosition(TextPosition(offset: chatStore.textController.text.length));
|
||||
},
|
||||
child: Text(matchingChatters[index]),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ class _ChatSettingsState extends State<ChatSettings> {
|
|||
),
|
||||
),
|
||||
children: [
|
||||
SwitchListTile.adaptive(
|
||||
isThreeLine: true,
|
||||
title: const Text('Autocomplete'),
|
||||
subtitle: const Text('Shows a bar that suggests matching emotes and mentions when typing.'),
|
||||
value: settingsStore.autocomplete,
|
||||
onChanged: settingsStore.showBottomBar ? (newValue) => settingsStore.autocomplete = newValue : null,
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
|
|
@ -108,13 +116,6 @@ class _ChatSettingsState extends State<ChatSettings> {
|
|||
fontSize: 12.0,
|
||||
padding: sectionPadding,
|
||||
),
|
||||
SwitchListTile.adaptive(
|
||||
isThreeLine: true,
|
||||
title: const Text('Emote Autocomplete'),
|
||||
subtitle: const Text('Shows a bar that suggests matching emotes when typing.'),
|
||||
value: settingsStore.emoteAutocomplete,
|
||||
onChanged: settingsStore.showBottomBar ? (newValue) => settingsStore.emoteAutocomplete = newValue : null,
|
||||
),
|
||||
SwitchListTile.adaptive(
|
||||
isThreeLine: true,
|
||||
title: const Text('Zero-Width Emotes'),
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ abstract class _SettingsStoreBase with Store {
|
|||
|
||||
static const defaultEmoteScale = 1.0;
|
||||
|
||||
static const defaultEmoteAutocomplete = true;
|
||||
static const defaultAutocomplete = true;
|
||||
|
||||
static const defaultChatWidth = 0.3;
|
||||
|
||||
|
|
@ -145,9 +145,9 @@ abstract class _SettingsStoreBase with Store {
|
|||
@observable
|
||||
var emoteScale = defaultEmoteScale;
|
||||
|
||||
@JsonKey(defaultValue: defaultEmoteAutocomplete)
|
||||
@JsonKey(defaultValue: defaultAutocomplete)
|
||||
@observable
|
||||
var emoteAutocomplete = defaultEmoteAutocomplete;
|
||||
var autocomplete = defaultAutocomplete;
|
||||
|
||||
@JsonKey(defaultValue: defaultChatWidth)
|
||||
@observable
|
||||
|
|
@ -218,7 +218,7 @@ abstract class _SettingsStoreBase with Store {
|
|||
messageSpacing = defaultMessageSpacing;
|
||||
badgeScale = defaultBadgeScale;
|
||||
emoteScale = defaultEmoteScale;
|
||||
emoteAutocomplete = defaultEmoteAutocomplete;
|
||||
autocomplete = defaultAutocomplete;
|
||||
chatWidth = defaultChatWidth;
|
||||
landscapeChatLeftSide = false;
|
||||
chatDelay = defaultChatDelay;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ SettingsStore _$SettingsStoreFromJson(Map<String, dynamic> json) =>
|
|||
..messageScale = (json['messageScale'] as num?)?.toDouble() ?? 1.0
|
||||
..badgeScale = (json['badgeScale'] as num?)?.toDouble() ?? 1.0
|
||||
..emoteScale = (json['emoteScale'] as num?)?.toDouble() ?? 1.0
|
||||
..emoteAutocomplete = json['emoteAutocomplete'] as bool? ?? true
|
||||
..autocomplete = json['autocomplete'] as bool? ?? true
|
||||
..chatWidth = (json['chatWidth'] as num?)?.toDouble() ?? 0.3
|
||||
..landscapeChatLeftSide = json['landscapeChatLeftSide'] as bool? ?? false
|
||||
..fullScreenChatOverlayOpacity =
|
||||
|
|
@ -67,7 +67,7 @@ Map<String, dynamic> _$SettingsStoreToJson(SettingsStore instance) =>
|
|||
'messageScale': instance.messageScale,
|
||||
'badgeScale': instance.badgeScale,
|
||||
'emoteScale': instance.emoteScale,
|
||||
'emoteAutocomplete': instance.emoteAutocomplete,
|
||||
'autocomplete': instance.autocomplete,
|
||||
'chatWidth': instance.chatWidth,
|
||||
'landscapeChatLeftSide': instance.landscapeChatLeftSide,
|
||||
'fullScreenChatOverlayOpacity': instance.fullScreenChatOverlayOpacity,
|
||||
|
|
@ -419,19 +419,19 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
|
|||
});
|
||||
}
|
||||
|
||||
late final _$emoteAutocompleteAtom =
|
||||
Atom(name: '_SettingsStoreBase.emoteAutocomplete', context: context);
|
||||
late final _$autocompleteAtom =
|
||||
Atom(name: '_SettingsStoreBase.autocomplete', context: context);
|
||||
|
||||
@override
|
||||
bool get emoteAutocomplete {
|
||||
_$emoteAutocompleteAtom.reportRead();
|
||||
return super.emoteAutocomplete;
|
||||
bool get autocomplete {
|
||||
_$autocompleteAtom.reportRead();
|
||||
return super.autocomplete;
|
||||
}
|
||||
|
||||
@override
|
||||
set emoteAutocomplete(bool value) {
|
||||
_$emoteAutocompleteAtom.reportWrite(value, super.emoteAutocomplete, () {
|
||||
super.emoteAutocomplete = value;
|
||||
set autocomplete(bool value) {
|
||||
_$autocompleteAtom.reportWrite(value, super.autocomplete, () {
|
||||
super.autocomplete = value;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -604,7 +604,7 @@ messageSpacing: ${messageSpacing},
|
|||
messageScale: ${messageScale},
|
||||
badgeScale: ${badgeScale},
|
||||
emoteScale: ${emoteScale},
|
||||
emoteAutocomplete: ${emoteAutocomplete},
|
||||
autocomplete: ${autocomplete},
|
||||
chatWidth: ${chatWidth},
|
||||
landscapeChatLeftSide: ${landscapeChatLeftSide},
|
||||
fullScreenChatOverlayOpacity: ${fullScreenChatOverlayOpacity},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue