Switch bot svg (#1654)
* fix: use bot face png for most bot faces to fix memory issues * fix: if no data in vocab popup, still show title
This commit is contained in:
parent
5bdb541b3f
commit
7a071dea77
5 changed files with 38 additions and 5 deletions
|
|
@ -34,6 +34,7 @@ class RoomCreationStateEvent extends StatelessWidget {
|
|||
name: roomName,
|
||||
// #Pangea
|
||||
presenceUserId: event.room.directChatMatrixID,
|
||||
useRive: true,
|
||||
// Pangea#
|
||||
size: Avatar.defaultSize * 2,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ class ChatListItem extends StatelessWidget {
|
|||
name: space.getLocalizedDisplayname(),
|
||||
// #Pangea
|
||||
presenceUserId: space.directChatMatrixID,
|
||||
useRive: true,
|
||||
// Pangea#
|
||||
onTap: () => onLongPress?.call(context),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -185,7 +185,17 @@ class LemmaListDialogContent extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (lemmas.isEmpty) {
|
||||
return Center(child: Text(L10n.of(context).noDataFound));
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(ProgressIndicatorEnum.wordsUsed.tooltip(context)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: Navigator.of(context).pop,
|
||||
),
|
||||
// TODO: add search and training buttons?
|
||||
),
|
||||
body: Center(child: Text(L10n.of(context).noDataFound)),
|
||||
);
|
||||
}
|
||||
|
||||
// Get lists of lemmas by category
|
||||
|
|
|
|||
|
|
@ -5,18 +5,22 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
|
||||
enum BotExpression { gold, nonGold, addled, idle, surprised }
|
||||
|
||||
class BotFace extends StatefulWidget {
|
||||
final double width;
|
||||
final Color? forceColor;
|
||||
final BotExpression expression;
|
||||
final bool useRive;
|
||||
|
||||
const BotFace({
|
||||
super.key,
|
||||
required this.width,
|
||||
required this.expression,
|
||||
this.forceColor,
|
||||
this.useRive = true,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -27,17 +31,20 @@ class BotFaceState extends State<BotFace> {
|
|||
Artboard? _artboard;
|
||||
StateMachineController? _controller;
|
||||
final Random _random = Random();
|
||||
final String svgURL = "${AppConfig.svgAssetsBaseURL}/bot_face_neutral.png";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadRiveFile().then((_) => _scheduleNextRun());
|
||||
if (widget.useRive) {
|
||||
_loadRiveFile().then((_) => _scheduleNextRun());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(BotFace oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.expression != widget.expression) {
|
||||
if (widget.useRive && oldWidget.expression != widget.expression) {
|
||||
_controller!.setInputValue(
|
||||
_controller!.stateMachine.inputs[0].id,
|
||||
mapExpressionToInput(widget.expression),
|
||||
|
|
@ -52,6 +59,8 @@ class BotFaceState extends State<BotFace> {
|
|||
}
|
||||
|
||||
void _scheduleNextRun() {
|
||||
if (!widget.useRive) return;
|
||||
|
||||
final int nextInterval =
|
||||
_random.nextInt(21) + 20; // Random interval between 20-40 seconds
|
||||
|
||||
|
|
@ -79,6 +88,8 @@ class BotFaceState extends State<BotFace> {
|
|||
}
|
||||
|
||||
Future<void> _loadRiveFile() async {
|
||||
if (!widget.useRive) return;
|
||||
|
||||
final riveFile =
|
||||
await RiveFile.asset('assets/pangea/bot_faces/pangea_bot.riv');
|
||||
|
||||
|
|
@ -111,7 +122,7 @@ class BotFaceState extends State<BotFace> {
|
|||
artboard: _artboard!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Container(),
|
||||
: Image.network(svgURL),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ class Avatar extends StatelessWidget {
|
|||
final BorderRadius? borderRadius;
|
||||
final IconData? icon;
|
||||
final BorderSide? border;
|
||||
// #Pangea
|
||||
final bool useRive;
|
||||
// Pangea#
|
||||
|
||||
const Avatar({
|
||||
this.mxContent,
|
||||
|
|
@ -32,6 +35,9 @@ class Avatar extends StatelessWidget {
|
|||
this.borderRadius,
|
||||
this.border,
|
||||
this.icon,
|
||||
// #Pangea
|
||||
this.useRive = false,
|
||||
// Pangea#
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -83,7 +89,11 @@ class Avatar extends StatelessWidget {
|
|||
child:
|
||||
// #Pangea
|
||||
presenceUserId == BotName.byEnvironment
|
||||
? BotFace(width: size, expression: BotExpression.idle)
|
||||
? BotFace(
|
||||
width: size,
|
||||
expression: BotExpression.idle,
|
||||
useRive: useRive,
|
||||
)
|
||||
:
|
||||
// Pangea#
|
||||
noPic
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue