mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
341 lines
14 KiB
Dart
341 lines
14 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
|
|
class SceneAutoSettings extends StatelessWidget {
|
|
const SceneAutoSettings({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final sceneSettings =
|
|
ModalRoute.of(context)!.settings.arguments as Map<String, dynamic>? ??
|
|
{};
|
|
final sceneId = sceneSettings['sceneId'] as String? ?? '';
|
|
final isAutomation = context.read<CreateSceneBloc>().sceneType ==
|
|
CreateSceneEnum.deviceStatusChanges;
|
|
final sceneName = sceneSettings['sceneName'] as String? ?? '';
|
|
|
|
return DefaultScaffold(
|
|
title: 'Settings',
|
|
padding: EdgeInsets.zero,
|
|
leading: IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
icon: const Icon(
|
|
Icons.arrow_back_ios,
|
|
)),
|
|
child: BlocProvider(
|
|
create: (BuildContext context) =>
|
|
CreateSceneBloc()..add(SceneIconEvent()),
|
|
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
|
builder: (context, state) {
|
|
return SizedBox(
|
|
height: MediaQuery.sizeOf(context).height,
|
|
child: Column(
|
|
children: [
|
|
DefaultContainer(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(
|
|
top: 10, left: 10, right: 10, bottom: 10),
|
|
child: Column(
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return SecondDialog(
|
|
WidgetList: BlocBuilder<CreateSceneBloc,
|
|
CreateSceneState>(
|
|
builder: (context, state) {
|
|
if (state is CreateSceneLoading) {
|
|
return CircularProgressIndicator();
|
|
} else if (state is CreateSceneLoaded) {
|
|
return Container(
|
|
height: 100,
|
|
width: 100,
|
|
child: ListView.builder(
|
|
itemCount:
|
|
state.iconModels.length,
|
|
itemBuilder: (context, index) {
|
|
final iconModel =
|
|
state.iconModels[index];
|
|
return Image.memory(
|
|
iconModel.iconBytes);
|
|
},
|
|
),
|
|
);
|
|
} else if (state is CreateSceneError) {
|
|
return Text(state.message);
|
|
} else {
|
|
return Container();
|
|
}
|
|
},
|
|
),
|
|
cancelTab: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
confirmTab: (v) {
|
|
Navigator.of(context).pop();
|
|
},
|
|
title: 'Icons',
|
|
onTapLabel1: (selected) {},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: const Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
BodyMedium(text: 'Icons'),
|
|
Icon(
|
|
Icons.arrow_forward_ios_outlined,
|
|
color: ColorsManager.textGray,
|
|
size: 15,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
const Divider(
|
|
color: ColorsManager.graysColor,
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const BodyMedium(text: 'Show on devices page'),
|
|
Container(
|
|
width: 100,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Container(
|
|
height: 30,
|
|
width: 1,
|
|
color: ColorsManager.graysColor,
|
|
),
|
|
Transform.scale(
|
|
scale: .8,
|
|
child: CupertinoSwitch(
|
|
value: true,
|
|
onChanged: (value) {},
|
|
applyTheme: true,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
const Divider(
|
|
color: ColorsManager.graysColor,
|
|
),
|
|
SizedBox(
|
|
height: 5,
|
|
),
|
|
const Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
//Cloud
|
|
BodyMedium(text: 'Executed by'),
|
|
Text('Cloud',
|
|
style: TextStyle(
|
|
color: ColorsManager.textGray,
|
|
)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
// Padding(
|
|
// padding: const EdgeInsets.symmetric(vertical: 16),
|
|
// child: DefaultContainer(
|
|
// child: Column(
|
|
// mainAxisSize: MainAxisSize.min,
|
|
// mainAxisAlignment: MainAxisAlignment.start,
|
|
// children: [
|
|
// const SizedBox(
|
|
// height: 8,
|
|
// ),
|
|
// Visibility(
|
|
// visible: isAutomation,
|
|
// child: SceneListTile(
|
|
// padding: const EdgeInsets.symmetric(
|
|
// horizontal: 16, vertical: 8),
|
|
// titleString: "Effective Period",
|
|
// trailingWidget:
|
|
// const Icon(Icons.arrow_forward_ios_rounded),
|
|
// onPressed: () {
|
|
// context.customBottomSheet(
|
|
// child: const EffectPeriodBottomSheetContent(),
|
|
// );
|
|
// },
|
|
// ),
|
|
// ),
|
|
// Visibility(
|
|
// visible: sceneName.isNotEmpty && isAutomation,
|
|
// child: SizedBox(
|
|
// width: context.width * 0.9,
|
|
// child: const Divider(
|
|
// color: ColorsManager.greyColor,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// Visibility(
|
|
// visible: sceneName.isNotEmpty,
|
|
// child: DeleteBottomSheetContent(
|
|
// isAutomation: isAutomation,
|
|
// sceneId: sceneId,
|
|
// ),
|
|
// ),
|
|
// const SizedBox(
|
|
// height: 16,
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
],
|
|
),
|
|
);
|
|
})));
|
|
}
|
|
}
|
|
|
|
class SecondDialog extends StatefulWidget {
|
|
final String title;
|
|
Widget WidgetList;
|
|
final Function(String)? onTapLabel1;
|
|
final Function()? cancelTab;
|
|
final Function(int selectedSecond)? confirmTab;
|
|
|
|
SecondDialog({
|
|
required this.WidgetList,
|
|
required this.title,
|
|
this.onTapLabel1,
|
|
required this.cancelTab,
|
|
required this.confirmTab,
|
|
});
|
|
|
|
@override
|
|
_SecondDialogState createState() => _SecondDialogState();
|
|
}
|
|
|
|
class _SecondDialogState extends State<SecondDialog> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
contentPadding: EdgeInsets.zero,
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
BodyLarge(
|
|
text: widget.title,
|
|
fontWeight: FontWeight.w700,
|
|
fontColor: ColorsManager.primaryColor,
|
|
fontSize: 16,
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(left: 15, right: 15),
|
|
child: Divider(
|
|
color: ColorsManager.textGray,
|
|
),
|
|
),
|
|
Expanded(child: widget.WidgetList),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
right: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 0.5,
|
|
),
|
|
top: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 1.0,
|
|
),
|
|
)),
|
|
child: SizedBox(
|
|
child: InkWell(
|
|
onTap: widget.cancelTab,
|
|
child: const Padding(
|
|
padding: EdgeInsets.all(15),
|
|
child: Center(
|
|
child: Text(
|
|
'Cancel',
|
|
style: TextStyle(
|
|
color: ColorsManager.textGray,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
left: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 0.5,
|
|
),
|
|
top: BorderSide(
|
|
color: ColorsManager.textGray,
|
|
width: 1.0,
|
|
),
|
|
)),
|
|
child: InkWell(
|
|
onTap: () {},
|
|
child: const Padding(
|
|
padding: EdgeInsets.all(15),
|
|
child: Center(
|
|
child: Text(
|
|
'Confirm',
|
|
style: TextStyle(
|
|
color: ColorsManager.primaryColor,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400),
|
|
),
|
|
),
|
|
)),
|
|
))
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|