mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 09:09:40 +00:00
76 lines
2.4 KiB
Dart
76 lines
2.4 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_bloc.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
|
|
class CurtainButtons extends StatelessWidget {
|
|
const CurtainButtons({super.key, required this.curtain});
|
|
final DeviceModel curtain;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
_buildButton(
|
|
onTap: () => context.read<CurtainBloc>().add(OpenCurtain(curtain.productType!)),
|
|
iconPath: Assets.assetsIconsCurtainsIconOpenCurtain,
|
|
),
|
|
_buildButton(
|
|
onTap: () => context.read<CurtainBloc>().add(PauseCurtain()),
|
|
iconPath: Assets.assetsImagesPause,
|
|
isSvg: false,
|
|
),
|
|
_buildButton(
|
|
onTap: () => context.read<CurtainBloc>().add(CloseCurtain(curtain.productType!)),
|
|
iconPath: Assets.assetsIconsCurtainsIconCloseCurtain,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildButton({
|
|
required VoidCallback onTap,
|
|
required String iconPath,
|
|
bool isSvg = true,
|
|
}) {
|
|
return Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.grey.withOpacity(0.5),
|
|
spreadRadius: 1,
|
|
blurRadius: 5,
|
|
offset: const Offset(3, 3),
|
|
),
|
|
],
|
|
),
|
|
child: InkWell(
|
|
overlayColor: MaterialStateProperty.all(Colors.transparent),
|
|
onTap: onTap,
|
|
child: const SizedBox.square(dimension: 60),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 5, bottom: 5),
|
|
child: InkWell(
|
|
overlayColor: MaterialStateProperty.all(Colors.transparent),
|
|
onTap: onTap,
|
|
child: isSvg
|
|
? SvgPicture.asset(iconPath, width: 110, height: 110)
|
|
: Image.asset(iconPath, width: 60, height: 60),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|