garage size

This commit is contained in:
mohammad
2024-10-09 15:22:11 +03:00
parent 465a2e3108
commit 82f08ddcd8

View File

@ -24,15 +24,17 @@ class GarageDoorScreen extends StatelessWidget {
return DefaultScaffold(
title: 'Garage Door Opener',
child: BlocProvider(
create: (context) =>
GarageDoorBloc(GDId: device?.uuid ?? '')..add(const GarageDoorInitial()),
create: (context) => GarageDoorBloc(GDId: device?.uuid ?? '')
..add(const GarageDoorInitial()),
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
builder: (context, state) {
final garageBloc = BlocProvider.of<GarageDoorBloc>(context);
return state is GarageDoorLoadingState
? const Center(
child:
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
@ -45,32 +47,38 @@ class GarageDoorScreen extends StatelessWidget {
child: Column(
children: [
Expanded(
flex: 4,
flex: 5,
child: InkWell(
overlayColor: WidgetStateProperty.all(Colors.transparent),
overlayColor: WidgetStateProperty.all(
Colors.transparent),
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(890),
borderRadius:
BorderRadius.circular(890),
boxShadow: [
BoxShadow(
color: Colors.white.withOpacity(0.1),
color: Colors.white
.withOpacity(0.1),
blurRadius: 24,
offset: const Offset(-5, -5),
blurStyle: BlurStyle.outer,
),
BoxShadow(
color: Colors.black.withOpacity(0.11),
color: Colors.black
.withOpacity(0.11),
blurRadius: 25,
offset: const Offset(5, 5),
blurStyle: BlurStyle.outer,
),
BoxShadow(
color: Colors.black.withOpacity(0.13),
color: Colors.black
.withOpacity(0.13),
blurRadius: 30,
offset: const Offset(5, 5),
blurStyle: BlurStyle.inner,
@ -79,177 +87,222 @@ class GarageDoorScreen extends StatelessWidget {
),
child: InkWell(
onTap: () {
garageBloc.add(
ToggleDoorEvent(toggle: garageBloc.toggleDoor));
garageBloc.add(ToggleDoorEvent(
toggle:
garageBloc.toggleDoor));
},
child: GradientWidget(
doorStatus: garageBloc.toggleDoor,
seconds: garageBloc.secondSelected,
seconds:
garageBloc.secondSelected,
),
)),
],
),
),
),
Flexible(
child: Row(
children: [
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => TimerScheduleScreen(
device: device!,
switchCode: 'switch_1',
deviceCode: 'countdown_1',
)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
Expanded(
flex: 3,
child: Column(
children: [
Flexible(
child: Row(
children: [
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(Assets.garageSchedule),
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
TimerScheduleScreen(
device: device!,
switchCode:
'switch_1',
deviceCode:
'countdown_1',
)),
);
},
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(
maxHeight: 46,
maxWidth: 50),
child: SvgPicture.asset(
Assets
.garageSchedule),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Schedule',
textAlign:
TextAlign.center,
),
),
),
],
),
),
),
const SizedBox(
height: 15,
width: 10,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Schedule',
textAlign: TextAlign.center,
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
TimerPage(
device: device!,
switchCode:
'switch_1',
deviceCode:
'countdown_1',
)),
);
},
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(
maxHeight: 46,
maxWidth: 50),
child: SvgPicture.asset(
Assets
.garageCountdown),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Countdown',
textAlign:
TextAlign.center,
),
),
),
],
),
),
),
],
),
),
),
const SizedBox(
width: 10,
),
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => TimerPage(
device: device!,
switchCode: 'switch_1',
deviceCode: 'countdown_1',
)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
const SizedBox(
height: 10,
),
Flexible(
child: Row(
children: [
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(Assets.garageCountdown),
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
GarageRecordsScreen(
GDId: device!
.uuid!)),
);
},
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(
maxHeight: 46,
maxWidth: 50),
child: SvgPicture.asset(
Assets
.doorRecordsIcon),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Records',
textAlign:
TextAlign.center,
),
),
),
],
),
),
),
const SizedBox(
height: 15,
width: 10,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Countdown',
textAlign: TextAlign.center,
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
PreferencesPage(
GDId: device!
.uuid!)),
);
},
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(
maxHeight: 46,
maxWidth: 50),
child: SvgPicture.asset(Assets
.garagePreferencesIcon),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Preferences',
textAlign:
TextAlign.center,
),
),
),
],
),
),
),
],
),
),
),
],
),
),
const SizedBox(
height: 10,
),
Flexible(
child: Row(
children: [
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
GarageRecordsScreen(GDId: device!.uuid!)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(Assets.doorRecordsIcon),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Records',
textAlign: TextAlign.center,
),
),
),
],
),
),
),
const SizedBox(
width: 10,
),
Expanded(
child: DefaultContainer(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
PreferencesPage(GDId: device!.uuid!)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 46, maxWidth: 50),
child: SvgPicture.asset(Assets.garagePreferencesIcon),
),
const SizedBox(
height: 15,
),
const Flexible(
child: FittedBox(
child: BodySmall(
text: 'Preferences',
textAlign: TextAlign.center,
),
),
),
],
),
),
),
],
),
)
)
],
)),
],
),
),
@ -272,7 +325,8 @@ class GradientWidget extends StatefulWidget {
State<GradientWidget> createState() => _GradientWidgetState();
}
class _GradientWidgetState extends State<GradientWidget> with SingleTickerProviderStateMixin {
class _GradientWidgetState extends State<GradientWidget>
with SingleTickerProviderStateMixin {
late ScrollController _scrollController;
late AnimationController _animationController;
late Animation<double> _itemExtentAnimation;
@ -285,15 +339,16 @@ class _GradientWidgetState extends State<GradientWidget> with SingleTickerProvid
vsync: this,
duration: Duration(seconds: widget.seconds),
);
_itemExtentAnimation =
Tween<double>(begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0).animate(
_itemExtentAnimation = Tween<double>(
begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0)
.animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
),
)..addListener(() {
setState(() {});
});
setState(() {});
});
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.doorStatus) {