pull to refresh

This commit is contained in:
mohammad
2024-07-03 16:48:46 +03:00
parent cef32e9bf3
commit 038ed680dd
6 changed files with 734 additions and 664 deletions

View File

@ -66,17 +66,22 @@ class ACsView extends StatelessWidget {
child: state is AcsLoadingState child: state is AcsLoadingState
? const Center( ? const Center(
child: DefaultContainer( child: DefaultContainer(
width: 50, height: 50, child: CircularProgressIndicator()), width: 50, height: 50, child: CircularProgressIndicator()),)
) : RefreshIndicator(
: Container( onRefresh: () async {
BlocProvider.of<ACsBloc>(context).add(AcsInitial(allAcs: deviceModel != null ? false : true));
},
child:ListView(
children: [
Container(
padding: const EdgeInsets.only(top: 40), padding: const EdgeInsets.only(top: 40),
alignment: AlignmentDirectional.center, alignment: AlignmentDirectional.center,
child: child: deviceModel != null ? AcInterface(ac: deviceModel!) : const ACsList(),
deviceModel != null ? AcInterface(ac: deviceModel!) : const ACsList(),
), ),
],
),),
), ),
), ));
);
}, },
), ),
); );

View File

@ -29,6 +29,7 @@ class CeilingSensorInterface extends StatelessWidget {
// .firstWhere((element) => element.code == "presence_state") // .firstWhere((element) => element.code == "presence_state")
// .value // .value
// .toString(); // .toString();
return BlocProvider( return BlocProvider(
create: (context) => create: (context) =>
CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()), CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()),
@ -69,14 +70,23 @@ class CeilingSensorInterface extends StatelessWidget {
child: state is LoadingInitialState child: state is LoadingInitialState
? const Center( ? const Center(
child: RefreshProgressIndicator(), child: RefreshProgressIndicator(),
) ) : SafeArea(
: SafeArea( child:
RefreshIndicator(
onRefresh: () async {
BlocProvider.of<CeilingSensorBloc>(context).add(InitialEvent());
},
child:Container(
child: ListView(
shrinkWrap: true,
children: [
Container(
height: MediaQuery.of(context).size.height,
child: Column( child: Column(
children: [ children: [
Expanded( Expanded(
flex: 1,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
// InkWell( // InkWell(
// onTap: () { // onTap: () {
@ -116,6 +126,7 @@ class CeilingSensorInterface extends StatelessWidget {
// }, // },
// child: // child:
// ), // ),
SvgPicture.asset( SvgPicture.asset(
ceilingSensorModel.presenceState.toLowerCase() == 'motion' ceilingSensorModel.presenceState.toLowerCase() == 'motion'
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion ? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
@ -150,8 +161,8 @@ class CeilingSensorInterface extends StatelessWidget {
), ),
), ),
Expanded( Expanded(
flex: 2, flex: 3,
child: ListView( child: Column(
children: [ children: [
DefaultContainer( DefaultContainer(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
@ -316,6 +327,12 @@ class CeilingSensorInterface extends StatelessWidget {
), ),
], ],
), ),
),
],
),
) ,
)
)), )),
), ),
); );

View File

@ -40,8 +40,7 @@ class GateWayView extends StatelessWidget {
extendBody: true, extendBody: true,
appBar:DeviceAppbar( appBar:DeviceAppbar(
deviceName: 'Gateway', deviceName: 'Gateway',
deviceUuid: gatewayObj.uuid!, deviceUuid: gatewayObj.uuid!,),
),
body: Container( body: Container(
width: MediaQuery.sizeOf(context).width, width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height, height: MediaQuery.sizeOf(context).height,
@ -55,6 +54,15 @@ class GateWayView extends StatelessWidget {
opacity: 0.4, opacity: 0.4,
), ),
), ),
child: RefreshIndicator(
onRefresh:()async {
BlocProvider.of<GatewayBloc>(context).add(GatewayInitial(gatewayId: gatewayObj.uuid ?? ''));
},
child: ListView(
children: [
Container(
height: MediaQuery.of(context).size.height,
child: SafeArea( child: SafeArea(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -129,7 +137,12 @@ class GateWayView extends StatelessWidget {
], ],
), ),
), ),
))); ),
],
),
),
)
));
})); }));
} }
} }

View File

@ -98,7 +98,14 @@ class DoorInterface extends StatelessWidget {
? const Center( ? const Center(
child: RefreshProgressIndicator(), child: RefreshProgressIndicator(),
) )
: Column( :
RefreshIndicator(
onRefresh: () async {
BlocProvider.of<SmartDoorBloc>(context).add(InitialEvent());
},
child:
ListView(
children: [ children: [
DoorLockStatusBar( DoorLockStatusBar(
smartDoorModel: smartDoorModel, smartDoorModel: smartDoorModel,
@ -120,7 +127,7 @@ class DoorInterface extends StatelessWidget {
), ),
), ),
), ),
); ));
}), }),
); );
} }

View File

@ -55,12 +55,21 @@ class ThreeGangScreen extends StatelessWidget {
threeGangList: groupThreeGangModel, threeGangList: groupThreeGangModel,
allSwitches: allSwitchesOn, allSwitches: allSwitchesOn,
) )
: Column( : RefreshIndicator(
onRefresh:()async {
BlocProvider.of<ThreeGangBloc>(context).add(InitialEvent(groupScreen: device != null ? false : true));
},
child: ListView(
children: [
SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const Expanded(child: SizedBox.shrink()), const Expanded(child: SizedBox.shrink()),
Row( Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
@ -147,6 +156,7 @@ class ThreeGangScreen extends StatelessWidget {
), ),
], ],
), ),
),
Expanded( Expanded(
child: Center( child: Center(
child: Row( child: Row(
@ -373,7 +383,12 @@ class ThreeGangScreen extends StatelessWidget {
), ),
), ),
), ),
Expanded(child: SizedBox())
], ],
),
),
],
),
); );
}, },
), ),

View File

@ -79,7 +79,17 @@ class WallMountedInterface extends StatelessWidget {
child: RefreshProgressIndicator(), child: RefreshProgressIndicator(),
) )
: SafeArea( : SafeArea(
child: RefreshIndicator(
onRefresh: () async {
BlocProvider.of<WallSensorBloc>(context).add(InitialEvent());
},
child:
ListView(
children: [
Container(
height: MediaQuery.of(context).size.height,
child: Column( child: Column(
children: [ children: [
PresenceIndicator( PresenceIndicator(
state: wallSensorModel.presenceState, state: wallSensorModel.presenceState,
@ -91,9 +101,12 @@ class WallMountedInterface extends StatelessWidget {
], ],
), ),
), ),
],
), ),
), ),
); ),
),
));
}), }),
); );
} }