Files
syncrow-app/lib/features/shared_widgets/custom_switch.dart
Mohammad Salameh 3fabd41e72 Stabilized UI elements across multiple devices
Synchronized ACs Status functionality
2024-02-28 12:22:45 +03:00

63 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class CustomSwitch extends StatelessWidget {
const CustomSwitch({super.key, required this.category});
final DevicesCategoryModel category;
@override
Widget build(BuildContext context) {
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return GestureDetector(
onTap: () {
DevicesCubit.get(context).changeCategorySwitchValue(category);
},
child: Container(
width: 45.0,
height: 28.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24.0),
color: category.devicesStatus
? ColorsManager.primaryColor
: const Color(0xFFD9D9D9),
),
child: Center(
child: Container(
width: 40.0,
height: 23.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24.0),
color: Colors.white,
),
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Container(
alignment: category.devicesStatus
? Alignment.centerRight
: Alignment.centerLeft,
child: Container(
width: 20.0,
height: 20.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: category.devicesStatus
? ColorsManager.primaryColor
: Colors.grey,
),
),
),
),
),
),
),
);
},
);
}
}