mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00

AC Cubit Add New Devices Cubit Arch will be used Devices Cubit (for devices categories, and devices page) { AC cubit, Lights cubit. ... } Replaced AssetsManager with Assets Class (auto generated)
76 lines
2.8 KiB
Dart
76 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
|
|
import '../../bloc/devices_cubit.dart';
|
|
|
|
class Switches extends StatelessWidget {
|
|
const Switches({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
|
builder: (context, state) {
|
|
return GridView.builder(
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
crossAxisSpacing: 10,
|
|
mainAxisSpacing: 10,
|
|
childAspectRatio: 1.5,
|
|
),
|
|
padding: const EdgeInsets.only(top: 10),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount: DevicesCubit.categories.length,
|
|
itemBuilder: (_, index) {
|
|
return InkWell(
|
|
onTap: () => DevicesCubit.get(context).updateCategory(index),
|
|
child: DefaultContainer(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
SvgPicture.asset(
|
|
DevicesCubit.categories[index].icon,
|
|
fit: BoxFit.contain,
|
|
),
|
|
const SizedBox(
|
|
width: 30,
|
|
height: 20,
|
|
child: CustomSwitch(
|
|
// value: DevicesCubit
|
|
// .categories[index]
|
|
// .switchValue,
|
|
//
|
|
// onChanged: (value) => DevicesCubit.get(context)
|
|
// .changeSwitchValue( DevicesCubit
|
|
// .categories[index]
|
|
// .switchValue),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
BodyLarge(
|
|
text: DevicesCubit.categories[index].name,
|
|
fontWeight: FontWeight.bold,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|