mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
built the interface for the blind curtains.
This commit is contained in:
@ -6,11 +6,14 @@ import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdo
|
||||
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/blind_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart';
|
||||
import 'package:syncrow_app/features/menu/view/menu_view.dart';
|
||||
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
part 'home_state.dart';
|
||||
@ -168,7 +171,14 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
foregroundColor:
|
||||
MaterialStateProperty.all(ColorsManager.textPrimaryColor),
|
||||
),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
NavigationService.navigatorKey.currentContext!,
|
||||
CustomPageRoute(
|
||||
builder: (context) => const BlindsView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
'Devices': [
|
||||
|
@ -391,45 +391,76 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
//////////////////////////////////CURTAINS//////////////////////////////////////
|
||||
double height = 310;
|
||||
double _openPercentage = 0;
|
||||
bool isMoving = false;
|
||||
|
||||
openCurtain() async {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (state is! CurtainsIsMoving) {
|
||||
if (state is CurtainsIsOpening) {
|
||||
return;
|
||||
}
|
||||
|
||||
isMoving = true;
|
||||
while (_openPercentage < 100.0) {
|
||||
if (state is CurtainsIsClosing) {
|
||||
// interrupted by the closing process
|
||||
pauseCurtain();
|
||||
break;
|
||||
}
|
||||
|
||||
emit(CurtainsIsMoving());
|
||||
emit(CurtainsIsOpening());
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 200), () {
|
||||
if (_openPercentage < 100.0) {
|
||||
if (isMoving) {
|
||||
await Future.delayed(const Duration(milliseconds: 200), () {
|
||||
_openPercentage += 10.0;
|
||||
height -= 24.5;
|
||||
} else {
|
||||
emit(CurtainsStopped());
|
||||
}
|
||||
});
|
||||
|
||||
if (_openPercentage >= 100.0) {
|
||||
print('done open');
|
||||
pauseCurtain();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
print('stopped open');
|
||||
pauseCurtain();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeCurtain() async {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (state is! CurtainsIsMoving) {
|
||||
if (state is CurtainsIsClosing) {
|
||||
return;
|
||||
}
|
||||
|
||||
isMoving = true;
|
||||
while (_openPercentage > 0.0) {
|
||||
if (state is CurtainsIsOpening) {
|
||||
// interrupted by the opening process
|
||||
pauseCurtain();
|
||||
break;
|
||||
}
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 200), () {
|
||||
if (_openPercentage > 0.0) {
|
||||
emit(CurtainsIsClosing());
|
||||
|
||||
if (isMoving) {
|
||||
await Future.delayed(const Duration(milliseconds: 200), () {
|
||||
_openPercentage -= 10.0;
|
||||
height += 24.5;
|
||||
emit(CurtainsIsMoving());
|
||||
} else {
|
||||
emit(CurtainsStopped());
|
||||
}
|
||||
});
|
||||
|
||||
if (_openPercentage <= 0.0) {
|
||||
print('done close');
|
||||
pauseCurtain();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
print('stopped close');
|
||||
pauseCurtain();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pauseCurtain() {
|
||||
isMoving = false;
|
||||
emit(CurtainsStopped());
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,8 @@ class DevicesCategoriesError extends DevicesState {
|
||||
}
|
||||
|
||||
// Curtains
|
||||
class CurtainsIsMoving extends DevicesState {}
|
||||
class CurtainsIsOpening extends DevicesState {}
|
||||
|
||||
class CurtainsIsClosing extends DevicesState {}
|
||||
|
||||
class CurtainsStopped extends DevicesState {}
|
||||
|
@ -9,21 +9,24 @@ class BlindsView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||
builder: (context, state) {
|
||||
return const DefaultScaffold(
|
||||
title: 'Blinds',
|
||||
child: Column(
|
||||
children: [
|
||||
Spacer(),
|
||||
BlindsBlades(),
|
||||
// SizedBox(height: 80),
|
||||
// BlindsBottons(),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
return BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||
builder: (context, state) {
|
||||
return const DefaultScaffold(
|
||||
title: 'Blinds',
|
||||
child: Column(
|
||||
children: [
|
||||
Spacer(),
|
||||
BlindsBlades(),
|
||||
// SizedBox(height: 80),
|
||||
// BlindsBottons(),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -392,7 +392,6 @@ enum MemberRole {
|
||||
OtherMember,
|
||||
}
|
||||
|
||||
//TODO sort memebers by role
|
||||
List<Map<String, Object>> members = [
|
||||
{
|
||||
'name': 'member 1',
|
||||
|
Reference in New Issue
Block a user