mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00
80 lines
2.6 KiB
Dart
80 lines
2.6 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_model.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
|
|
class DevicesDefaultSwitch extends StatelessWidget {
|
|
const DevicesDefaultSwitch({
|
|
super.key,
|
|
required this.model,
|
|
});
|
|
|
|
final DeviceModel model;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
|
builder: (context, state) {
|
|
return Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
DevicesCubit.getInstance().turnOnOffDevice(model);
|
|
},
|
|
child: Container(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: model.isOnline ?? false
|
|
? ColorsManager.primaryColor
|
|
: Colors.white,
|
|
borderRadius: const BorderRadius.only(
|
|
topLeft: Radius.circular(15),
|
|
bottomLeft: Radius.circular(15),
|
|
),
|
|
),
|
|
child: Center(
|
|
child: BodyMedium(
|
|
text: "ON",
|
|
fontColor: model.isOnline ?? false ? Colors.white : null,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
DevicesCubit.getInstance().turnOnOffDevice(model);
|
|
},
|
|
child: Container(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: model.isOnline ?? false
|
|
? Colors.white
|
|
: ColorsManager.primaryColor,
|
|
borderRadius: const BorderRadius.only(
|
|
topRight: Radius.circular(15),
|
|
bottomRight: Radius.circular(15),
|
|
),
|
|
),
|
|
child: Center(
|
|
child: BodyMedium(
|
|
text: "OFF",
|
|
fontColor: model.isOnline ?? false ? null : Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|