mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Refactor screen titles to use bloc device info
This commit is contained in:
@ -28,7 +28,15 @@ class SettingsPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
child: DefaultScaffold(
|
||||
title: 'Device Settings',
|
||||
child: BlocProvider(
|
||||
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
|
||||
@ -40,8 +48,10 @@ class SettingsPage extends StatelessWidget {
|
||||
|
||||
return state is DeviceSettingLoadingState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: ListView(
|
||||
children: [
|
||||
@ -65,29 +75,36 @@ class SettingsPage extends StatelessWidget {
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
DefaultContainer(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(30)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 90),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 90),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
child: Text(
|
||||
_bloc.deviceInfo.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight:
|
||||
FontWeight.w700,
|
||||
color: ColorsManager
|
||||
.grayColor,
|
||||
),
|
||||
overflow: TextOverflow
|
||||
.ellipsis, // Adds ellipsis (...) when the text overflows.
|
||||
@ -98,7 +115,10 @@ class SettingsPage extends StatelessWidget {
|
||||
height: 5,
|
||||
),
|
||||
BodySmall(
|
||||
text: _bloc.deviceInfo.subspace.subspaceName),
|
||||
text: _bloc
|
||||
.deviceInfo
|
||||
.subspace
|
||||
.subspaceName),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -125,10 +145,13 @@ class SettingsPage extends StatelessWidget {
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 40,
|
||||
backgroundColor: ColorsManager.backgroundColor,
|
||||
backgroundColor:
|
||||
ColorsManager.backgroundColor,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
device!.type == 'NCPS'
|
||||
? SizedBox(
|
||||
@ -138,26 +161,36 @@ class SettingsPage extends StatelessWidget {
|
||||
Assets.flushIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
):
|
||||
device!.type == "SOS"
|
||||
)
|
||||
: device!.type == "SOS"
|
||||
? ClipOval(
|
||||
child: SvgPicture.asset(
|
||||
child:
|
||||
SvgPicture.asset(
|
||||
Assets.sosHomeIcon,
|
||||
fit: BoxFit.contain,
|
||||
height: 70,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: device!.type == "4S"
|
||||
? const EdgeInsets.only(top: 5)
|
||||
: const EdgeInsets.only(top: 0),
|
||||
padding: device!
|
||||
.type ==
|
||||
"4S"
|
||||
? const EdgeInsets
|
||||
.only(top: 5)
|
||||
: const EdgeInsets
|
||||
.only(top: 0),
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: SvgPicture.asset(
|
||||
device!.type == "4S"
|
||||
? Assets.fourSceneIcon
|
||||
: Assets.sixSceneIcon,
|
||||
fit: BoxFit.contain,
|
||||
child: SvgPicture
|
||||
.asset(
|
||||
device!.type ==
|
||||
"4S"
|
||||
? Assets
|
||||
.fourSceneIcon
|
||||
: Assets
|
||||
.sixSceneIcon,
|
||||
fit: BoxFit
|
||||
.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -346,7 +379,8 @@ class SettingsPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
@ -355,10 +389,12 @@ class SettingsPage extends StatelessWidget {
|
||||
builder: (context) {
|
||||
return DisconnectDeviceDialog(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -368,7 +404,8 @@ class SettingsPage extends StatelessWidget {
|
||||
text: 'Disconnect Device',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15,
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
fontColor: ColorsManager
|
||||
.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
@ -379,7 +416,8 @@ class SettingsPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
@ -388,20 +426,24 @@ class SettingsPage extends StatelessWidget {
|
||||
builder: (context) {
|
||||
return DisconnectWipeData(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
_bloc.add(DeleteDeviceEvent());
|
||||
_bloc.add(
|
||||
DeleteDeviceEvent());
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const BodyMedium(
|
||||
text: 'Disconnect Device and Wipe Data',
|
||||
text:
|
||||
'Disconnect Device and Wipe Data',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15,
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
fontColor: ColorsManager
|
||||
.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
@ -430,6 +472,7 @@ class SettingsPage extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
model = state.device;
|
||||
}
|
||||
return DefaultScaffold(
|
||||
title: device?.name ?? '6 Scene Switch',
|
||||
title: bloc.deviceInfo.name ,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
@ -55,7 +55,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
builder: (context) => SettingsPage(device: device!),
|
||||
),
|
||||
);
|
||||
if (val == null) {
|
||||
if (val == null || val == true) {
|
||||
bloc.add(const SixSceneInitialInfo());
|
||||
bloc.add(const SixSceneInitial());
|
||||
bloc.add(const SexSceneSwitchInitial());
|
||||
@ -195,8 +195,8 @@ class SixSceneScreen extends StatelessWidget {
|
||||
);
|
||||
if (value == true) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 200),
|
||||
() {
|
||||
const Duration(
|
||||
milliseconds: 200), () {
|
||||
bloc.add(
|
||||
const SexSceneSwitchInitial());
|
||||
});
|
||||
|
@ -47,7 +47,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
return DefaultScaffold(
|
||||
title: device?.name ?? '4 Scene',
|
||||
title: _bloc.deviceInfo.name,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
@ -56,7 +56,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
builder: (context) => SettingsPage(device: device!),
|
||||
),
|
||||
);
|
||||
if (val == null) {
|
||||
if (val == null || val == true) {
|
||||
_bloc.add(const FourSceneInitial());
|
||||
_bloc.add(const FourSceneInitialInfo());
|
||||
_bloc.add(const FourSceneSwitchInitial());
|
||||
@ -164,8 +164,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab:
|
||||
(switchSelected) {
|
||||
confirmTab: (switchSelected) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
|
@ -29,7 +29,7 @@ class SosScreen extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(context);
|
||||
return DefaultScaffold(
|
||||
title: device?.name,
|
||||
title: sensor.deviceInfo.name,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
@ -38,7 +38,7 @@ class SosScreen extends StatelessWidget {
|
||||
builder: (context) => SettingsPage(device: device!),
|
||||
),
|
||||
);
|
||||
if (val == null) {
|
||||
if (val == null || val == true) {
|
||||
sensor.add(SosInitialDeviseInfo());
|
||||
sensor.add(const SosInitial());
|
||||
}
|
||||
@ -72,33 +72,38 @@ class SosScreen extends StatelessWidget {
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: InkWell(
|
||||
overlayColor:
|
||||
WidgetStateProperty.all(Colors.transparent),
|
||||
overlayColor: WidgetStateProperty.all(
|
||||
Colors.transparent),
|
||||
onTap: () {
|
||||
// Add functionality for the main SOS button here
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(890),
|
||||
borderRadius:
|
||||
BorderRadius.circular(890),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
color:
|
||||
Colors.white.withOpacity(0.1),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(-5, -5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.11),
|
||||
color: Colors.black
|
||||
.withOpacity(0.11),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.13),
|
||||
color: Colors.black
|
||||
.withOpacity(0.13),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.inner,
|
||||
@ -125,7 +130,8 @@ class SosScreen extends StatelessWidget {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SosRecordsScreen(
|
||||
builder: (context) =>
|
||||
SosRecordsScreen(
|
||||
sosId: device!.uuid!),
|
||||
),
|
||||
);
|
||||
@ -181,8 +187,8 @@ class SosScreen extends StatelessWidget {
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.doorNotificationSetting),
|
||||
child: SvgPicture.asset(Assets
|
||||
.doorNotificationSetting),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
|
Reference in New Issue
Block a user