import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scanutt/app/services/services.dart';
import 'package:scanutt/common/my_flare.dart';
import 'package:scanutt/common/widgets/level_bounce_button.dart';
import 'package:scanutt/common/widgets/home_topbar_widget.dart';
import 'package:scanutt/common/my_theme.dart';
import 'package:scanutt/common/app_images.dart';
import 'home_indicator.dart';
import 'package:flare_flutter/flare_actor.dart';
import 'home_flr_controller.dart';
import 'homeenum.dart';
import 'package:flare_flutter/flare_cache_builder.dart';
import 'package:flare_flutter/provider/asset_flare.dart';
import 'package:flutter/services.dart' show rootBundle;
class HomeStatusView extends StatefulWidget {
@override
_HomeStatusViewState createState() => _HomeStatusViewState();
}
class _HomeStatusViewState extends State<HomeStatusView> {
final double indicatorWidth = 350.0;
final double indicatorHeight = 100.0;
final double slideHeight = 200.0;
final double slideWidth = 400.0;
// int indicatortype = 0;
indicatorenum indicatortype = indicatorenum.food;
final LayerLink layerLink = LayerLink();
OverlayEntry overlayEntry;
Offset indicatorOffset;
final FocusNode _focusNode = FocusNode();
FlrAnimationController _normalController;
FlrAnimationController _eatdrinkController;
FlrAnimationController _playController;
FlrAnimationController _bathController;
FlrAnimationController _pillowController;
String sFlrFileName = AppImages.Scanutt_EatDrink_V001;
bool normalFlrVisible = true;
bool foodFlrVisible = false;
bool toyFlrVisible = false;
bool bathFlrVisible = false;
bool pillowFlrVisible = false;
bool foodItemsVisible = false;
bool toyItemsVisible = false;
bool bathItemsVisible = false;
bool pillowItemsVisible = false;
//record button 's global position
GlobalKey buttonRowkey = GlobalKey();
GlobalKey foodButtonkey = GlobalKey();
double newOverlayPositionY = 100.0;
void initState() {
///declare this here
_eatdrinkController = FlrAnimationController(indicatorenum.food);
_playController = FlrAnimationController(indicatorenum.toy);
_normalController = FlrAnimationController(indicatorenum.normal);
_bathController = FlrAnimationController(indicatorenum.bath);
_pillowController = FlrAnimationController(indicatorenum.pillow);
_focusNode.addListener(() {
if (_focusNode.hasFocus) {
} else {
this.overlayEntry.remove();
}
});
// stackChildren = <Widget>[
// //play flr
// FlareActor(
// "assets/toyimages/Scanutt_Play_V001.flr",
// controller: _playController,
// animation: "idle",
// ),
// // food flr
// FlareActor(
// sFlrFileName,
// controller: _eatdrinkController,
// animation: "idle",
// ),
// ];
// foodFlr = stackChildren[1];
// toyFlr = stackChildren[0];
super.initState();
}
@override
void dispose() {
// TODO: implement dispose
print("Go To other Screen");
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry = null;
}
super.dispose();
}
Offset _getIndicatorOffset(Offset dragOffset) {
final double x = (dragOffset.dx - (indicatorWidth / 2.0)).clamp(0.0, slideWidth - indicatorWidth);
final double y = (slideHeight - indicatorHeight) / 2.0;
return Offset(x, y);
}
void showIndicatorfoodnew() {
RenderBox box = buttonRowkey.currentContext.findRenderObject();
final sizeRed = box.size;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
final sizeOfFirstButton = boxOfFoodButton.size;
print('food button size is ');
print(sizeOfFirstButton);
Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
print('first button global x is $xOfFoodButton');
print('overlay global x is ');
print(0 + MediaQuery.of(context).size.width * 0.05);
print('overlay global y is ');
print(MediaQuery.of(context).size.width * 0.9);
indicatortype = indicatorenum.food;
setState(() {
foodItemsVisible = true;
toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = false;
newOverlayPositionY = y - indicatorHeight;
// newOverlayPositionY = 150;
toyFlrVisible = false;
foodFlrVisible = true;
normalFlrVisible = false;
bathFlrVisible = false;
});
}
void showIndicatortoynew() {
RenderBox box = buttonRowkey.currentContext.findRenderObject();
final sizeRed = box.size;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
final sizeOfFirstButton = boxOfFoodButton.size;
print('food button size is ');
print(sizeOfFirstButton);
Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
print('first button global x is $xOfFoodButton');
print('overlay global x is ');
print(0 + MediaQuery.of(context).size.width * 0.05);
print('overlay global y is ');
print(MediaQuery.of(context).size.width * 0.9);
indicatortype = indicatorenum.toy;
setState(() {
toyItemsVisible = true;
foodItemsVisible = false;
// toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = false;
newOverlayPositionY = y - indicatorHeight;
toyFlrVisible = true;
foodFlrVisible = false;
normalFlrVisible = false;
bathFlrVisible = false;
// newOverlayPositionY = 150;
});
}
void showIndicatorbathnew() {
RenderBox box = buttonRowkey.currentContext.findRenderObject();
final sizeRed = box.size;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
final sizeOfFirstButton = boxOfFoodButton.size;
print('food button size is ');
print(sizeOfFirstButton);
Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
print('first button global x is $xOfFoodButton');
print('overlay global x is ');
print(0 + MediaQuery.of(context).size.width * 0.05);
print('overlay global y is ');
print(MediaQuery.of(context).size.width * 0.9);
indicatortype = indicatorenum.bath;
setState(() {
foodItemsVisible = false;
toyItemsVisible = false;
bathItemsVisible = true;
pillowItemsVisible = false;
newOverlayPositionY = y - indicatorHeight;
toyFlrVisible = false;
foodFlrVisible = false;
normalFlrVisible = false;
bathFlrVisible = true;
// newOverlayPositionY = 150;
});
}
void showIndicatorpillownew() {
RenderBox box = buttonRowkey.currentContext.findRenderObject();
final sizeRed = box.size;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
final sizeOfFirstButton = boxOfFoodButton.size;
print('food button size is ');
print(sizeOfFirstButton);
Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
print('first button global x is $xOfFoodButton');
print('overlay global x is ');
print(0 + MediaQuery.of(context).size.width * 0.05);
print('overlay global y is ');
print(MediaQuery.of(context).size.width * 0.9);
indicatortype = indicatorenum.pillow;
setState(() {
foodItemsVisible = false;
toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = true;
newOverlayPositionY = y - indicatorHeight;
// newOverlayPositionY = 150;
toyFlrVisible = false;
foodFlrVisible = false;
normalFlrVisible = true;
bathFlrVisible = false;
});
}
void showIndicatorfood() {
if (overlayEntry != null) {
overlayEntry.remove();
}
indicatortype = indicatorenum.food;
print("button type is $indicatortype");
setState(() {
toyFlrVisible = false;
foodFlrVisible = true;
normalFlrVisible = false;
bathFlrVisible = false;
});
// final temp = stackChildren[0];
// setState(() {
// stackChildren[0] = toyFlr;
// stackChildren[1] = foodFlr;
// });
RenderBox box = buttonRowkey.currentContext.findRenderObject();
final sizeRed = box.size;
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
final sizeOfFirstButton = boxOfFoodButton.size;
print('food button size is ');
print(sizeOfFirstButton);
Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
print('first button global x is $xOfFoodButton');
print('overlay global x is ');
print(0 + MediaQuery.of(context).size.width * 0.05);
print('overlay global y is ');
print(MediaQuery.of(context).size.width * 0.9);
overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Positioned(
//top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: y - indicatorHeight,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width : sizeRed.width,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(0.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.15,
type: indicatortype,
),
),
);
},
);
Overlay.of(context).insert(overlayEntry);
}
void showIndicatortoy(TapDownDetails details) {
if (overlayEntry != null) {
overlayEntry.remove();
}
indicatortype = indicatorenum.toy;
print("button type is $indicatortype");
RenderBox box = buttonRowkey.currentContext.findRenderObject();
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
setState(() {
toyFlrVisible = true;
foodFlrVisible = false;
normalFlrVisible = false;
bathFlrVisible = false;
});
// final temp = toyFlr;
// setState(() {
// stackChildren[0] = foodFlr;
// stackChildren[1] = toyFlr;
// });
overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Positioned(
// top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: y - indicatorHeight,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width: indicatorWidth,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(50.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.35,
type: indicatortype,
),
),
);
},
);
Overlay.of(context).insert(overlayEntry);
}
void showIndicatorbath(TapDownDetails details) {
if (overlayEntry != null) {
overlayEntry.remove();
}
indicatortype = indicatorenum.bath;
print("button type is $indicatortype");
RenderBox box = buttonRowkey.currentContext.findRenderObject();
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
setState(() {
toyFlrVisible = false;
foodFlrVisible = false;
normalFlrVisible = true;
bathFlrVisible = false;
});
overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Positioned(
// top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: y - indicatorHeight,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width: indicatorWidth,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(50.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.50,
type: indicatortype,
),
),
);
},
);
Overlay.of(context).insert(overlayEntry);
}
void showIndicatorpie(TapDownDetails details) {
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry = null;
}
Get.find<ScanuttService>().usePee().then((value) => {});
// indicatortype = indicatorenum.toy;
// print("button type is $indicatortype");
// RenderBox box = buttonRowkey.currentContext.findRenderObject();
// Offset position = box.localToGlobal(Offset.zero); //this is global position
// double y = position.dy; //this is y - I think it's what you want
// overlayEntry = OverlayEntry(
// builder: (BuildContext context) {
// return Positioned(
// // top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// // left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
// top: y - indicatorHeight,
// left: 0 + MediaQuery.of(context).size.width * 0.05,
// // left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// // top : indicatorOffset.dx,
// // left:indicatorOffset.dy,
// child: SizedBox(
// width: MediaQuery.of(context).size.width * 0.9,
// // width: indicatorWidth,
// height: indicatorHeight,
// child: HomeIndicator(
// //offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
// offset: new Offset(50.0, 0.0),
// link: layerLink,
// // arrowpositionX: (details.globalPosition.dx + 30) /
// // MediaQuery.of(context).size.width *
// // 0.8,
// arrowpositionX: 0.7,
// type: indicatortype,
// ),
// ),
// );
// },
// );
// Overlay.of(context).insert(overlayEntry);
}
void showIndicatorpillow(TapDownDetails details) {
if (overlayEntry != null) {
overlayEntry.remove();
}
indicatortype = indicatorenum.pillow;
print("button type is $indicatortype");
RenderBox box = buttonRowkey.currentContext.findRenderObject();
Offset position = box.localToGlobal(Offset.zero); //this is global position
double y = position.dy; //this is y - I think it's what you want
overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Positioned(
// top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: y - indicatorHeight,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width: indicatorWidth,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(50.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.85,
type: indicatortype,
),
),
);
},
);
Overlay.of(context).insert(overlayEntry);
}
void _updateIndicator(DragUpdateDetails details) {
indicatorOffset = _getIndicatorOffset(details.localPosition);
overlayEntry.markNeedsBuild();
}
void hideIndicator(DragEndDetails details) {
overlayEntry.remove();
}
void whenSthDropToScanutt(DragEndDetails details) {
print("when something drop down here");
}
@override
Widget build(BuildContext context) {
// indicatortype = indicatorenum.food;
// print("button type is $indicatortype");
// RenderBox box = buttonRowkey.currentContext.findRenderObject();
// final sizeRed = box.size;
// Offset position = box.localToGlobal(Offset.zero); //this is global position
// double y = position.dy; //this is y - I think it's what you want
// RenderBox boxOfFoodButton = foodButtonkey.currentContext.findRenderObject();
// final sizeOfFirstButton = boxOfFoodButton.size;
// print('food button size is ');
// print(sizeOfFirstButton);
// Offset positionOfFoodButton = boxOfFoodButton.localToGlobal(Offset.zero); //this is global position
// double xOfFoodButton = positionOfFoodButton.dx; //this is y - I think it's what you want
// print('first button global x is $xOfFoodButton');
// print('overlay global x is ');
// print(0 + MediaQuery.of(context).size.width * 0.05);
// print('overlay global y is ');
// print(MediaQuery.of(context).size.width * 0.9);
return Stack(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
HomeTopBarWidget(),
DragTarget(
builder: (context, List<String> food, rejectedData) {
return Container(
width: MyTheme.getResponsiveWidth(500),
height: MediaQuery.of(context).size.height * 0.6,
child: GestureDetector(
onTap: () {
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry = null;
}
setState(() {
toyFlrVisible = false;
foodFlrVisible = false;
normalFlrVisible = true;
bathFlrVisible = false;
foodItemsVisible = false;
toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = false;
});
},
onPanEnd: whenSthDropToScanutt,
child: Stack(
children: <Widget>[
// first fill whole width
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.6,
child: Image.asset(
AppImages.Scanutt_Home_Background,
fit: BoxFit.fill,
),
),
Container(
width: 540, //pic 's real width
height: MediaQuery.of(context).size.height * 0.6,
child: Image.asset(
AppImages.Scanutt_Home_Background,
fit: BoxFit.fill,
),
),
Visibility(
visible: normalFlrVisible,
child:
// FlareActor(
// "assets/homeimages/Scanutt_MainStatus_V001.flr",
// controller: _normalController,
// animation: "Blink",
// ),
FlareCacheBuilder(
[AssetFlare(bundle: rootBundle, name: MyFlare.flvMainStatus)],
builder: (BuildContext context, bool isWarm) {
return !isWarm
? Container(child: Text("Loading..."))
: FlareActor(
MyFlare.flvMainStatus,
controller: _normalController,
alignment: Alignment.center,
fit: BoxFit.contain,
animation: "Blink",
);
},
),
),
// Stack(
// children: stackChildren,
// food flr
Visibility(
visible: foodFlrVisible,
child:
//"assets/foodimages/Scanutt_EatDrink_V001.flr"
FlareCacheBuilder(
[AssetFlare(bundle: rootBundle, name: MyFlare.flvDrink)],
builder: (BuildContext context, bool isWarm) {
return !isWarm
? Container(child: Text("Loading..."))
: FlareActor(
MyFlare.flvDrink,
controller: _eatdrinkController,
alignment: Alignment.center,
fit: BoxFit.contain,
animation: "idle",
);
},
),
// FlareActor(
// // "assets/foodimages/Scanutt_EatDrink_V001.flr",
// //AppImages.Scanutt_EatDrink_V001,
// sFlrFileName,
// controller: _eatdrinkController,
// animation: "idle",
// ),
),
//play flr
Visibility(
visible: toyFlrVisible,
child: FlareCacheBuilder(
[AssetFlare(bundle: rootBundle, name: MyFlare.flvPlay)],
builder: (BuildContext context, bool isWarm) {
return !isWarm
? Container(child: Text("Loading..."))
: FlareActor(
MyFlare.flvPlay,
controller: _playController,
alignment: Alignment.center,
fit: BoxFit.contain,
animation: "idle",
);
},
),
// FlareActor(
// "assets/toyimages/Scanutt_Play_V001.flr",
// controller: _playController,
// animation: "idle",
// ),
),
//bath flr
Visibility(
visible: bathFlrVisible,
child: FlareCacheBuilder(
[AssetFlare(bundle: rootBundle, name: MyFlare.flvWash)],
builder: (BuildContext context, bool isWarm) {
return !isWarm
? Container(child: Text("Loading..."))
: FlareActor(
MyFlare.flvWash,
controller: _bathController,
alignment: Alignment.center,
fit: BoxFit.contain,
animation: "idle",
);
},
),
// FlareActor(
// "assets/bathimages/Scanutt_Wash_V1.flr",
// controller: _bathController,
// animation: "idle",
// ),
),
// Visibility(
// visible: foodItemsVisible,
// child:Positioned(
// //top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// // left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
// //top: newOverlayPositionY * 0.6,
// // top: 300,
// left: 0 + MediaQuery.of(context).size.width * 0.05,
// bottom : 0,
// // left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// // top : indicatorOffset.dx,
// // left:indicatorOffset.dy,
// child: SizedBox(
// width: MediaQuery.of(context).size.width * 0.9,
// // width : sizeRed.width,
// height: indicatorHeight,
// child: HomeIndicator(
// //offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
// offset: new Offset(0.0, 0.0),
// link: layerLink,
// // arrowpositionX: (details.globalPosition.dx + 30) /
// // MediaQuery.of(context).size.width *
// // 0.8,
// arrowpositionX: 0.15,
// type: indicatortype,
// ),
// ),
// ),
// ),
// ),
//stackChildren,
],
),
),
);
},
onWillAccept: (data) {
return true;
},
onAccept: (data) {
print("data = $data"); // data is a int number , mean foods 's index begin at 0
//fullness or happyness +1
switch (indicatortype) {
case indicatorenum.food:
//play flr of eat drink
_eatdrinkController.play(data.toString());
// Get.find<ScanuttService>().useFood(data).then((value) => {});
// print('now fullness value is ');
// print(Get.find<ScanuttService>().lvFullness);
// if (Get.find<ScanuttService>().lvFullness >= 100) {
// _eatdrinkController.play("EatFull");
// } else {
// if ((data.toString() == 'FOOD_DRINKS_APPLE_JUICE') ||
// (data.toString() == 'FOOD_DRINKS_BUBBLE_TEA_FRUITY') ||
// (data.toString() == 'FOOD_DRINKS_BUBBLE_TEA_NORMAL') ||
// (data.toString() == 'FOOD_DRINKS_CHOCOLATE_MILK') ||
// (data.toString() == 'FOOD_DRINKS_MILK') ||
// (data.toString() == 'FOOD_DRINKS_ORANGE_JUICE') ||
// (data.toString() == 'FOOD_DRINKS_SOFT_DRINK') ||
// (data.toString() == 'FOOD_DRINKS_WATER')) {
// _eatdrinkController.play("Drink");
// } else {
// _eatdrinkController.play("Eat");
// }
// }
setState(() {
foodItemsVisible = true;
toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = false;
});
break;
case indicatorenum.toy:
// toy
_playController.play(data.toString());
// Get.find<ScanuttService>().ince;
//Get.find<ScanuttService>().useToy(data).then((value) => {});
setState(() {
foodItemsVisible = false;
toyItemsVisible = true;
bathItemsVisible = false;
pillowItemsVisible = false;
});
break;
case indicatorenum.bath:
// bath
setState(() {
foodItemsVisible = false;
toyItemsVisible = false;
bathItemsVisible = true;
pillowItemsVisible = false;
});
_bathController.play(data.toString());
// Get.find<ScanuttService>().useBath(data).then((value) => {});
break;
case indicatorenum.pillow:
// pillow
// _playController.play("Football");
Get.find<ScanuttService>().usePillow(data).then((value) => {});
setState(() {
foodItemsVisible = false;
toyItemsVisible = false;
bathItemsVisible = false;
pillowItemsVisible = true;
});
break;
}
},
),
// Container(
// height: MediaQuery.of(context).size.height * 0.05,
// color: Colors.black,
// ),
// SizedBox(height: MyTheme.getResponsiveHeight(100),color:Colors.black),
// Positioned(
// //top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// // left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
// top: 0,
// left: 0 + MediaQuery.of(context).size.width * 0.25,
// // left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// // top : indicatorOffset.dx,
// // left:indicatorOffset.dy,
// child: SizedBox(
// width: MediaQuery.of(context).size.width * 0.9,
// // width : sizeRed.width,
// height: indicatorHeight,
// child: HomeIndicator(
// //offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
// offset: new Offset(0.0, 0.0),
// link: layerLink,
// // arrowpositionX: (details.globalPosition.dx + 30) /
// // MediaQuery.of(context).size.width *
// // 0.8,
// arrowpositionX: 0.15,
// type: indicatortype,
// ),
// ),
// ),
Expanded(
child: Container(
width: MyTheme.getResponsiveWidth(500),
//height: MediaQuery.of(context).size.height * 0.15,
height: double.infinity,
color: Colors.black,
padding: EdgeInsets.only(top: 5),
child: Row(
key: buttonRowkey,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
// onTapDown: showIndicatorfood,
//onTapDown: showIndicatorfoodnew,
child: Container(
key: foodButtonkey,
child: BounceButton(
// key: foodButtonkey,
width: MyTheme.getResponsiveWidth(60),
height: MyTheme.getResponsiveWidth(60), //MyTheme.getResponsiveHeight(60),
buttonType: ButtonType.eat,
onPressed: () {
showIndicatorfoodnew();
print("food button onpress");
}),
),
),
SizedBox(width: MyTheme.getResponsiveWidth(5)),
GestureDetector(
// onTapDown: showIndicatortoynew,
child: BounceButton(
width: MyTheme.getResponsiveWidth(60),
height: MyTheme.getResponsiveWidth(60), //MyTheme.getResponsiveHeight(60),
buttonType: ButtonType.play,
onPressed: () {
showIndicatortoynew();
print("toy button onpress");
// indicatortype = indicatorenum.toy;
}),
),
SizedBox(width: MyTheme.getResponsiveWidth(5)),
GestureDetector(
// onTapDown: showIndicatorbathnew,
child: BounceButton(
width: MyTheme.getResponsiveWidth(60),
height: MyTheme.getResponsiveWidth(60), //MyTheme.getResponsiveHeight(60),
buttonType: ButtonType.shower,
onPressed: () {
showIndicatorbathnew();
print('bath button onPressed');
}),
),
SizedBox(width: MyTheme.getResponsiveWidth(5)),
GestureDetector(
onTapDown: showIndicatorpie,
child: BounceButton(
width: MyTheme.getResponsiveWidth(60),
height: MyTheme.getResponsiveWidth(60), //MyTheme.getResponsiveHeight(60),
buttonType: ButtonType.toilet,
onPressed: () {
print('onPressed at mainpage');
}),
),
SizedBox(width: MyTheme.getResponsiveWidth(5)),
GestureDetector(
// onTapDown: showIndicatorpillownew,
child: BounceButton(
width: MyTheme.getResponsiveWidth(60),
height: MyTheme.getResponsiveWidth(60), //MyTheme.getResponsiveHeight(60),
buttonType: ButtonType.sleep,
onPressed: () {
showIndicatorpillownew();
print('onPressed at mainpage');
}),
),
],
),
),
),
],
),
Visibility(
visible: foodItemsVisible,
child: Positioned(
//top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: newOverlayPositionY,
// top: 300,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// bottom : 0,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width : sizeRed.width,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(0.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.15,
type: indicatorenum.food,
),
),
),
),
Visibility(
visible: toyItemsVisible,
child: Positioned(
//top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: newOverlayPositionY,
// top: 300,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// bottom : 0,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width : sizeRed.width,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(0.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.35,
type: indicatorenum.toy,
),
),
),
),
Visibility(
visible: bathItemsVisible,
child: Positioned(
//top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: newOverlayPositionY,
// top: 300,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// bottom : 0,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width : sizeRed.width,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(0.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.5,
type: indicatorenum.bath,
),
),
),
),
Visibility(
visible: pillowItemsVisible,
child: Positioned(
//top: (details.globalPosition.dy ~/ 100) * 100 - indicatorHeight,
// left: details.globalPosition.dx - MediaQuery.of(context).size.width * 0.8 / 3 ,
top: newOverlayPositionY,
// top: 300,
left: 0 + MediaQuery.of(context).size.width * 0.05,
// bottom : 0,
// left: details.globalPosition.dx - indicatorWidth / 2 < 0 ? 0 : details.globalPosition.dx - indicatorWidth / 2 ,
// top : indicatorOffset.dx,
// left:indicatorOffset.dy,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
// width : sizeRed.width,
height: indicatorHeight,
child: HomeIndicator(
//offset: new Offset(indicatorOffset.dx,indicatorOffset.dy - 50),
offset: new Offset(0.0, 0.0),
link: layerLink,
// arrowpositionX: (details.globalPosition.dx + 30) /
// MediaQuery.of(context).size.width *
// 0.8,
arrowpositionX: 0.85,
type: indicatorenum.pillow,
),
),
),
),
],
); // column
}
}