mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
switched the safe area to be in the scaffold
This commit is contained in:
@ -7,6 +7,7 @@ import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart';
|
|||||||
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/smart_linkage_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/smart_linkage_view.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
@ -19,23 +20,12 @@ class AppLayout extends StatelessWidget {
|
|||||||
create: (context) => HomeCubit.getInstance(),
|
create: (context) => HomeCubit.getInstance(),
|
||||||
child: BlocBuilder<HomeCubit, HomeState>(
|
child: BlocBuilder<HomeCubit, HomeState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return AnnotatedRegion(
|
return DefaultScaffold(
|
||||||
value: SystemUiOverlayStyle(
|
appBar: HomeCubit.getInstance().spaces != null
|
||||||
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
? const DefaultAppBar()
|
||||||
statusBarIconBrightness: Brightness.light,
|
: null,
|
||||||
),
|
bottomNavBar: const DefaultNavBar(),
|
||||||
child: SafeArea(
|
child: const AppBody(),
|
||||||
child: Scaffold(
|
|
||||||
backgroundColor: ColorsManager.backgroundColor,
|
|
||||||
extendBodyBehindAppBar: true,
|
|
||||||
extendBody: true,
|
|
||||||
appBar: HomeCubit.getInstance().spaces != null
|
|
||||||
? const DefaultAppBar()
|
|
||||||
: null,
|
|
||||||
body: const AppBody(),
|
|
||||||
bottomNavigationBar: const DefaultNavBar(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -15,32 +15,20 @@ class AppBody extends StatelessWidget {
|
|||||||
return BlocConsumer<HomeCubit, HomeState>(
|
return BlocConsumer<HomeCubit, HomeState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is GetSpacesError) {
|
if (state is GetSpacesError) {
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).removeCurrentSnackBar();
|
||||||
// SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
// content: Text(state.errMessage),
|
SnackBar(
|
||||||
// ),
|
content: Text(state.errMessage),
|
||||||
// );
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Container(
|
return state is! GetSpacesLoading
|
||||||
width: MediaQuery.sizeOf(context).width,
|
? state is! GetSpaceRoomsLoading
|
||||||
height: MediaQuery.sizeOf(context).height,
|
? HomeCubit.getInstance().pages[HomeCubit.pageIndex]
|
||||||
decoration: const BoxDecoration(
|
: const Center(child: CircularProgressIndicator())
|
||||||
image: DecorationImage(
|
: const Center(child: CircularProgressIndicator());
|
||||||
image: AssetImage(
|
|
||||||
Assets.imagesBackground,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
opacity: 0.4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: state is! GetSpacesLoading
|
|
||||||
? state is! GetSpaceRoomsLoading
|
|
||||||
? HomeCubit.getInstance().pages[HomeCubit.pageIndex]
|
|
||||||
: const Center(child: CircularProgressIndicator())
|
|
||||||
: const Center(child: CircularProgressIndicator()),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
||||||
|
|
||||||
class DefaultNavBar extends StatelessWidget {
|
class DefaultNavBar extends StatelessWidget {
|
||||||
const DefaultNavBar({
|
const DefaultNavBar({
|
||||||
@ -15,34 +14,23 @@ class DefaultNavBar extends StatelessWidget {
|
|||||||
return BlocBuilder<HomeCubit, HomeState>(
|
return BlocBuilder<HomeCubit, HomeState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
var cubit = HomeCubit.getInstance();
|
var cubit = HomeCubit.getInstance();
|
||||||
return SizedBox(
|
return BottomNavigationBar(
|
||||||
height: Constants.bottomNavBarHeight,
|
backgroundColor: Colors.transparent,
|
||||||
child: BottomNavigationBar(
|
onTap: (int index) {
|
||||||
backgroundColor: Colors.transparent,
|
cubit.updatePageIndex(index);
|
||||||
onTap: (int index) {
|
HomeCubit.getInstance().updatePageIndex(index);
|
||||||
cubit.updatePageIndex(index);
|
},
|
||||||
// if (DevicesCubit.getInstance().chosenCategoryView != null) {
|
currentIndex: HomeCubit.pageIndex,
|
||||||
// DevicesCubit.getInstance()
|
selectedItemColor: ColorsManager.primaryColor,
|
||||||
// .clearCategoriesSelection(context);
|
selectedLabelStyle: const TextStyle(
|
||||||
// }
|
color: ColorsManager.primaryColor,
|
||||||
// if (HomeCubit.getInstance().selectedRoom != null) {
|
fontSize: 10,
|
||||||
// HomeCubit.getInstance().unselectRoom();
|
|
||||||
// }
|
|
||||||
|
|
||||||
HomeCubit.getInstance().updatePageIndex(index);
|
|
||||||
},
|
|
||||||
currentIndex: HomeCubit.pageIndex,
|
|
||||||
selectedItemColor: ColorsManager.primaryColor,
|
|
||||||
selectedLabelStyle: const TextStyle(
|
|
||||||
color: ColorsManager.primaryColor,
|
|
||||||
fontSize: 10,
|
|
||||||
),
|
|
||||||
showUnselectedLabels: true,
|
|
||||||
unselectedItemColor: Colors.grey,
|
|
||||||
type: BottomNavigationBarType.fixed,
|
|
||||||
elevation: 0,
|
|
||||||
items: HomeCubit.bottomNavItems,
|
|
||||||
),
|
),
|
||||||
|
showUnselectedLabels: true,
|
||||||
|
unselectedItemColor: Colors.grey,
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
|
elevation: 0,
|
||||||
|
items: HomeCubit.bottomNavItems,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -15,45 +15,36 @@ class DashboardView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return SingleChildScrollView(
|
||||||
padding: EdgeInsets.only(
|
child: Column(
|
||||||
top: Constants.appBarHeight,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
left: Constants.defaultPadding,
|
children: [
|
||||||
right: Constants.defaultPadding,
|
const TitleMedium(
|
||||||
bottom: Constants.bottomNavBarHeight,
|
text: StringsManager.dashboard,
|
||||||
),
|
style: TextStyle(
|
||||||
child: SingleChildScrollView(
|
fontSize: 32,
|
||||||
child: Column(
|
fontWeight: FontWeight.bold,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
const TitleMedium(
|
|
||||||
text: StringsManager.dashboard,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const LiveMonitorTab(),
|
),
|
||||||
const SizedBox(height: 10),
|
const LiveMonitorTab(),
|
||||||
const EnergyUsage(),
|
const SizedBox(height: 10),
|
||||||
Container(
|
const EnergyUsage(),
|
||||||
padding: const EdgeInsets.only(top: 20),
|
Container(
|
||||||
constraints: const BoxConstraints(
|
padding: const EdgeInsets.only(top: 20),
|
||||||
minHeight: 220,
|
constraints: const BoxConstraints(
|
||||||
maxHeight: 240,
|
minHeight: 220,
|
||||||
),
|
maxHeight: 240,
|
||||||
child: const Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Consumption(),
|
|
||||||
SizedBox(height: 20),
|
|
||||||
CarbonEmission(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
child: const Column(
|
||||||
),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Consumption(),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
CarbonEmission(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
@ -9,11 +8,18 @@ import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
|||||||
|
|
||||||
class DefaultScaffold extends StatelessWidget {
|
class DefaultScaffold extends StatelessWidget {
|
||||||
const DefaultScaffold(
|
const DefaultScaffold(
|
||||||
{super.key, required this.child, this.title, this.actions});
|
{super.key,
|
||||||
|
required this.child,
|
||||||
|
this.title,
|
||||||
|
this.actions,
|
||||||
|
this.appBar,
|
||||||
|
this.bottomNavBar});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final String? title;
|
final String? title;
|
||||||
final List<Widget>? actions;
|
final List<Widget>? actions;
|
||||||
|
final PreferredSizeWidget? appBar;
|
||||||
|
final Widget? bottomNavBar;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AnnotatedRegion(
|
return AnnotatedRegion(
|
||||||
@ -26,20 +32,22 @@ class DefaultScaffold extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar: appBar ??
|
||||||
backgroundColor: Colors.transparent,
|
AppBar(
|
||||||
centerTitle: true,
|
backgroundColor: Colors.transparent,
|
||||||
title: BodyLarge(
|
centerTitle: true,
|
||||||
text: title ?? "",
|
title: BodyLarge(
|
||||||
fontColor: ColorsManager.primaryColor,
|
text: title ?? "",
|
||||||
fontWeight: FontsManager.bold,
|
fontColor: ColorsManager.primaryColor,
|
||||||
),
|
fontWeight: FontsManager.bold,
|
||||||
actions: actions,
|
),
|
||||||
),
|
actions: actions,
|
||||||
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
padding: const EdgeInsets.all(Constants.defaultPadding),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: Constants.defaultPadding),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: AssetImage(
|
image: AssetImage(
|
||||||
@ -51,6 +59,7 @@ class DefaultScaffold extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: SafeArea(child: child),
|
child: SafeArea(child: child),
|
||||||
),
|
),
|
||||||
|
bottomNavigationBar: bottomNavBar,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ abstract class Constants {
|
|||||||
|
|
||||||
static const String countryCode = "US";
|
static const String countryCode = "US";
|
||||||
|
|
||||||
static const double appBarHeightPercentage = 0.12;
|
static const double appBarHeightPercentage = 0.1;
|
||||||
static const double bottomNavBarHeightPercentage = 0.1175;
|
static const double bottomNavBarHeightPercentage = 0.1;
|
||||||
static late double appBarHeight;
|
static late double appBarHeight;
|
||||||
static late double bottomNavBarHeight;
|
static late double bottomNavBarHeight;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user