diff --git a/assets/pangea/bot_faces/pangea_bot.riv b/assets/pangea/bot_faces/pangea_bot.riv new file mode 100644 index 000000000..b6956e547 Binary files /dev/null and b/assets/pangea/bot_faces/pangea_bot.riv differ diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index f29bb59b2..ba14aa095 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -231,30 +231,6 @@ class ITController { _setSourceText(); getTranslationData(false); - /*sourceText = newSourceText; - final String currentText = choreographer.currentText; - - choreographer.startLoading(); - - final List responses = await Future.wait([ - _customInputTranslation(""), - _customInputTranslation(choreographer.currentText), - ]); - if (responses[0].goldContinuances != null && - responses[0].goldContinuances!.isNotEmpty) { - goldRouteTracker = GoldRouteTracker( - responses[0].goldContinuances!, - sourceText!, - ); - } - currentITStep = CurrentITStep( - sourceText: sourceText!, - currentText: currentText, - responseModel: responses[1], - storedGoldContinuances: goldRouteTracker.continuances, - ); - - _addPayloadId(responses[1]);*/ } catch (err, stack) { debugger(when: kDebugMode); if (err is! http.Response) { diff --git a/lib/pangea/controllers/user_controller.dart b/lib/pangea/controllers/user_controller.dart index 0e336fdf6..c6a1b3409 100644 --- a/lib/pangea/controllers/user_controller.dart +++ b/lib/pangea/controllers/user_controller.dart @@ -142,7 +142,7 @@ class UserController extends BaseController { await updateMatrixProfile( dateOfBirth: dob, - autoPlayMessages: autoPlay, + autoPlayMessages: autoPlay ?? false, activatedFreeTrial: trial, interactiveTranslator: interactiveTranslator, itAutoPlay: itAutoPlay, diff --git a/lib/pangea/widgets/common/bot_face_svg.dart b/lib/pangea/widgets/common/bot_face_svg.dart index 718f10c90..b856596dd 100644 --- a/lib/pangea/widgets/common/bot_face_svg.dart +++ b/lib/pangea/widgets/common/bot_face_svg.dart @@ -1,8 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:rive/rive.dart'; enum BotExpression { surprised, right, addled, left, down, shocked } -class BotFace extends StatelessWidget { +class BotFace extends StatefulWidget { + final double width; + final Color? forceColor; + final BotExpression expression; + const BotFace({ super.key, required this.width, @@ -10,21 +15,68 @@ class BotFace extends StatelessWidget { this.forceColor, }); - final double width; - final Color? forceColor; - final BotExpression expression; + @override + BotFaceState createState() => BotFaceState(); +} + +class BotFaceState extends State { + Artboard? _artboard; + SMINumber? _input; + + @override + void initState() { + super.initState(); + _loadRiveFile(); + } + + double mapExpressionToInput(BotExpression expression) { + switch (expression) { + case BotExpression.surprised: + return 1.0; + case BotExpression.right: + return 2.0; + case BotExpression.shocked: + return 3.0; + case BotExpression.addled: + return 4.0; + default: + return 0.0; + } + } + + Future _loadRiveFile() async { + final riveFile = await RiveFile.asset('assets/pangea/bot_faces/pangea_bot.riv'); + + final artboard = riveFile.mainArtboard; + final controller = StateMachineController + .fromArtboard(artboard, 'BotIconStateMachine'); + + if (controller != null) { + artboard.addController(controller); + _input = controller.findInput("Enter State") as SMINumber?; + controller.setInputValue( + 890, // this should be the id of the input + mapExpressionToInput(widget.expression), + ); + } + + setState(() { + _artboard = artboard; + }); + } @override Widget build(BuildContext context) { - return Image.asset( - 'assets/pangea/bot_faces/${expression.toString().split('.').last}.png', - // 'assets/pangea/bot_faces/surprised.png', - width: width, - height: width, - // color: forceColor ?? - // (Theme.of(context).brightness == Brightness.light - // ? Theme.of(context).colorScheme.primary - // : Theme.of(context).colorScheme.primary), + + return SizedBox( + width: widget.width, + height: widget.width, + child: _artboard != null + ? Rive( + artboard: _artboard!, + fit: BoxFit.cover, + ) + : Container(), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 0c3b2faac..e8d93c8d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -124,6 +124,7 @@ dependencies: sentry_flutter: ^8.2.0 shimmer: ^3.0.0 syncfusion_flutter_xlsio: ^25.1.40 + rive: 0.11.11 # Pangea# dev_dependencies: @@ -212,4 +213,4 @@ dependency_overrides: keyboard_shortcuts: git: url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git - ref: null-safety \ No newline at end of file + ref: null-safety