Fix web avatars
This commit is contained in:
parent
285d840023
commit
f44a7e4df8
|
@ -42,12 +42,10 @@ class Avatar extends StatelessWidget {
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: size / 2,
|
radius: size / 2,
|
||||||
backgroundImage: !noPic
|
backgroundImage: !noPic
|
||||||
? kIsWeb
|
? AdvancedNetworkImage(
|
||||||
? NetworkImage(src)
|
src,
|
||||||
: AdvancedNetworkImage(
|
useDiskCache: !kIsWeb,
|
||||||
src,
|
)
|
||||||
useDiskCache: true,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
backgroundColor: noPic
|
backgroundColor: noPic
|
||||||
? name?.color ?? Theme.of(context).secondaryHeaderColor
|
? name?.color ?? Theme.of(context).secondaryHeaderColor
|
||||||
|
|
|
@ -51,12 +51,10 @@ class ContentBanner extends StatelessWidget {
|
||||||
? Image(
|
? Image(
|
||||||
height: 300,
|
height: 300,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
image: kIsWeb
|
image: AdvancedNetworkImage(
|
||||||
? NetworkImage(src)
|
src,
|
||||||
: AdvancedNetworkImage(
|
useDiskCache: !kIsWeb,
|
||||||
src,
|
),
|
||||||
useDiskCache: true,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: Icon(defaultIcon, size: 300)
|
: Icon(defaultIcon, size: 300)
|
||||||
: Icon(defaultIcon, size: 300),
|
: Icon(defaultIcon, size: 300),
|
||||||
|
|
|
@ -49,12 +49,15 @@ class InputBar extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, String>> getSuggestions(String text) {
|
List<Map<String, String>> getSuggestions(String text) {
|
||||||
if (controller.selection.baseOffset != controller.selection.extentOffset || controller.selection.baseOffset < 0) {
|
if (controller.selection.baseOffset != controller.selection.extentOffset ||
|
||||||
|
controller.selection.baseOffset < 0) {
|
||||||
return []; // no entries if there is selected text
|
return []; // no entries if there is selected text
|
||||||
}
|
}
|
||||||
final searchText = controller.text.substring(0, controller.selection.baseOffset);
|
final searchText =
|
||||||
|
controller.text.substring(0, controller.selection.baseOffset);
|
||||||
final ret = <Map<String, String>>[];
|
final ret = <Map<String, String>>[];
|
||||||
final emojiMatch = RegExp(r'(?:\s|^):(?:([-\w]+)~)?([-\w]+)$').firstMatch(searchText);
|
final emojiMatch =
|
||||||
|
RegExp(r'(?:\s|^):(?:([-\w]+)~)?([-\w]+)$').firstMatch(searchText);
|
||||||
if (emojiMatch != null) {
|
if (emojiMatch != null) {
|
||||||
final packSearch = emojiMatch[1];
|
final packSearch = emojiMatch[1];
|
||||||
final emoteSearch = emojiMatch[2].toLowerCase();
|
final emoteSearch = emojiMatch[2].toLowerCase();
|
||||||
|
@ -116,9 +119,7 @@ class InputBar extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Image(
|
Image(
|
||||||
image: kIsWeb
|
image: AdvancedNetworkImage(url, useDiskCache: !kIsWeb),
|
||||||
? NetworkImage(url)
|
|
||||||
: AdvancedNetworkImage(url, useDiskCache: true),
|
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
),
|
),
|
||||||
|
@ -160,9 +161,13 @@ class InputBar extends StatelessWidget {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final insertText = isUnique ? insertEmote : ':${insertPack}~${insertEmote.substring(1)}';
|
final insertText =
|
||||||
final replaceText = controller.text.substring(0, controller.selection.baseOffset);
|
isUnique ? insertEmote : ':${insertPack}~${insertEmote.substring(1)}';
|
||||||
final afterText = replaceText == controller.text ? '' : controller.text.substring(controller.selection.baseOffset + 1);
|
final replaceText =
|
||||||
|
controller.text.substring(0, controller.selection.baseOffset);
|
||||||
|
final afterText = replaceText == controller.text
|
||||||
|
? ''
|
||||||
|
: controller.text.substring(controller.selection.baseOffset + 1);
|
||||||
final startText = replaceText.replaceAllMapped(
|
final startText = replaceText.replaceAllMapped(
|
||||||
RegExp(r'(\s|^)(:(?:[-\w]+~)?[-\w]+)$'),
|
RegExp(r'(\s|^)(:(?:[-\w]+~)?[-\w]+)$'),
|
||||||
(Match m) => '${m[1]}${insertText} ',
|
(Match m) => '${m[1]}${insertText} ',
|
||||||
|
@ -194,12 +199,15 @@ class InputBar extends StatelessWidget {
|
||||||
hideOnEmpty: true,
|
hideOnEmpty: true,
|
||||||
hideOnLoading: true,
|
hideOnLoading: true,
|
||||||
keepSuggestionsOnSuggestionSelected: true,
|
keepSuggestionsOnSuggestionSelected: true,
|
||||||
debounceDuration: Duration(milliseconds: 50), // show suggestions after 50ms idle time (default is 300)
|
debounceDuration: Duration(
|
||||||
|
milliseconds:
|
||||||
|
50), // show suggestions after 50ms idle time (default is 300)
|
||||||
textFieldConfiguration: TextFieldConfiguration(
|
textFieldConfiguration: TextFieldConfiguration(
|
||||||
minLines: minLines,
|
minLines: minLines,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
keyboardType: keyboardType,
|
keyboardType: keyboardType,
|
||||||
onSubmitted: (text) { // fix for library for now
|
onSubmitted: (text) {
|
||||||
|
// fix for library for now
|
||||||
onSubmitted(text);
|
onSubmitted(text);
|
||||||
},
|
},
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
|
@ -211,10 +219,13 @@ class InputBar extends StatelessWidget {
|
||||||
),
|
),
|
||||||
suggestionsCallback: getSuggestions,
|
suggestionsCallback: getSuggestions,
|
||||||
itemBuilder: buildSuggestion,
|
itemBuilder: buildSuggestion,
|
||||||
onSuggestionSelected: (Map<String, String> suggestion) => insertSuggestion(context, suggestion),
|
onSuggestionSelected: (Map<String, String> suggestion) =>
|
||||||
|
insertSuggestion(context, suggestion),
|
||||||
errorBuilder: (BuildContext context, Object error) => Container(),
|
errorBuilder: (BuildContext context, Object error) => Container(),
|
||||||
loadingBuilder: (BuildContext context) => Container(), // fix loading briefly flickering a dark box
|
loadingBuilder: (BuildContext context) =>
|
||||||
noItemsFoundBuilder: (BuildContext context) => Container(), // fix loading briefly showing no suggestions
|
Container(), // fix loading briefly flickering a dark box
|
||||||
|
noItemsFoundBuilder: (BuildContext context) =>
|
||||||
|
Container(), // fix loading briefly showing no suggestions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,12 +335,10 @@ class _EmoteImage extends StatelessWidget {
|
||||||
method: ThumbnailMethod.scale,
|
method: ThumbnailMethod.scale,
|
||||||
);
|
);
|
||||||
return Image(
|
return Image(
|
||||||
image: kIsWeb
|
image: AdvancedNetworkImage(
|
||||||
? NetworkImage(url)
|
url,
|
||||||
: AdvancedNetworkImage(
|
useDiskCache: !kIsWeb,
|
||||||
url,
|
),
|
||||||
useDiskCache: true,
|
|
||||||
),
|
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
|
|
Loading…
Reference in a new issue