Files
syncrow-app/lib/features/shared_widgets/devices_default_switch.dart
2024-06-26 22:30:56 +03:00

73 lines
2.1 KiB
Dart

import 'package:flutter/material.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.switchValue, required this.action, this.secondAction});
final bool switchValue;
final Function action;
final Function? secondAction;
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Expanded(
child: InkWell(
onTap: () {
action();
},
child: Container(
height: 60,
decoration: BoxDecoration(
color: switchValue ? ColorsManager.primaryColor : Colors.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(15),
bottomLeft: Radius.circular(15),
),
),
child: Center(
child: BodyMedium(
text: "ON",
fontColor: switchValue ? Colors.white : null,
fontWeight: FontWeight.bold,
),
),
),
),
),
Expanded(
child: InkWell(
onTap: () {
if (secondAction != null) {
secondAction!();
} else {
action();
}
},
child: Container(
height: 60,
decoration: BoxDecoration(
color: switchValue ? Colors.white : ColorsManager.primaryColor,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(15),
bottomRight: Radius.circular(15),
),
),
child: Center(
child: BodyMedium(
text: "OFF",
fontColor: switchValue ? null : Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
);
}
}