Added New Bot with Animations

pull/1384/head
Matthew 1 year ago
parent 94f87a5312
commit 89e726b963

@ -231,30 +231,6 @@ class ITController {
_setSourceText();
getTranslationData(false);
/*sourceText = newSourceText;
final String currentText = choreographer.currentText;
choreographer.startLoading();
final List<ITResponseModel> 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) {

@ -142,7 +142,7 @@ class UserController extends BaseController {
await updateMatrixProfile(
dateOfBirth: dob,
autoPlayMessages: autoPlay,
autoPlayMessages: autoPlay ?? false,
activatedFreeTrial: trial,
interactiveTranslator: interactiveTranslator,
itAutoPlay: itAutoPlay,

@ -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<BotFace> {
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<void> _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(),
);
}
}

@ -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
ref: null-safety

Loading…
Cancel
Save