Merge pull request #6 from SyncrowIOT/ui_modifications

UI modifications
This commit is contained in:
Mohammad Salameh
2024-03-11 13:08:26 +03:00
committed by GitHub
23 changed files with 230 additions and 150 deletions
+13
View File
@@ -0,0 +1,13 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Scan">
<path id="Vector" d="M17.8383 0H15.0391C14.7155 0 14.4531 0.262344 14.4531 0.585938C14.4531 0.909531 14.7155 1.17188 15.0391 1.17188H17.8383C18.3841 1.17188 18.8281 1.61594 18.8281 2.16176V4.96094C18.8281 5.28453 19.0905 5.54688 19.4141 5.54688C19.7377 5.54688 20 5.28453 20 4.96094V2.16176C20 0.969766 19.0302 0 17.8383 0Z" fill="#5D5D5D"/>
<path id="Vector_2" d="M0.585938 5.54688C0.909531 5.54688 1.17188 5.28453 1.17188 4.96094V2.16176C1.17188 1.61594 1.61594 1.17188 2.16172 1.17188H4.96094C5.28453 1.17188 5.54688 0.909531 5.54688 0.585938C5.54688 0.262344 5.28453 0 4.96094 0H2.16172C0.969766 0 0 0.969766 0 2.16176V4.96094C0 5.28453 0.262344 5.54688 0.585938 5.54688Z" fill="#5D5D5D"/>
<path id="Vector_3" d="M4.96094 18.8281H2.16172C1.61594 18.8281 1.17188 18.3841 1.17188 17.8382V15.0391C1.17188 14.7155 0.909531 14.4531 0.585938 14.4531C0.262344 14.4531 0 14.7155 0 15.0391V17.8382C0 19.0302 0.969766 20 2.16172 20H4.96094C5.28453 20 5.54688 19.7377 5.54688 19.4141C5.54688 19.0905 5.28453 18.8281 4.96094 18.8281Z" fill="#5D5D5D"/>
<path id="Vector_4" d="M19.4141 14.4531C19.0905 14.4531 18.8281 14.7155 18.8281 15.0391V17.8382C18.8281 18.3841 18.3841 18.8281 17.8383 18.8281H15.0391C14.7155 18.8281 14.4531 19.0905 14.4531 19.4141C14.4531 19.7377 14.7155 20 15.0391 20H17.8383C19.0303 20 20 19.0302 20 17.8382V15.0391C20 14.7155 19.7377 14.4531 19.4141 14.4531Z" fill="#5D5D5D"/>
<path id="Vector_5" d="M13.3455 4.29688H15.2039C15.4576 4.29688 15.6641 4.50332 15.6641 4.75711V6.61547C15.6641 6.93906 15.9264 7.20141 16.25 7.20141C16.5736 7.20141 16.836 6.93906 16.836 6.61547V4.75711C16.836 3.85715 16.1038 3.125 15.2039 3.125H13.3455C13.0219 3.125 12.7595 3.38734 12.7595 3.71094C12.7595 4.03453 13.0219 4.29688 13.3455 4.29688Z" fill="#5D5D5D"/>
<path id="Vector_6" d="M3.16406 4.75711V6.61547C3.16406 6.93906 3.42641 7.20141 3.75 7.20141C4.07359 7.20141 4.33594 6.93906 4.33594 6.61547V4.75711C4.33594 4.50332 4.54242 4.29688 4.79617 4.29688H6.65457C6.97816 4.29688 7.24051 4.03453 7.24051 3.71094C7.24051 3.38734 6.97816 3.125 6.65457 3.125H4.79617C3.89625 3.125 3.16406 3.85715 3.16406 4.75711Z" fill="#5D5D5D"/>
<path id="Vector_7" d="M6.65457 15.625H4.79617C4.54238 15.625 4.33594 15.4185 4.33594 15.1648V13.3064C4.33594 12.9828 4.07359 12.7205 3.75 12.7205C3.42641 12.7205 3.16406 12.9828 3.16406 13.3064V15.1648C3.16406 16.0647 3.89625 16.7969 4.79617 16.7969H6.65457C6.97816 16.7969 7.24051 16.5345 7.24051 16.2109C7.24051 15.8873 6.97816 15.625 6.65457 15.625Z" fill="#5D5D5D"/>
<path id="Vector_8" d="M16.836 15.1648V13.3064C16.836 12.9828 16.5736 12.7205 16.25 12.7205C15.9264 12.7205 15.6641 12.9828 15.6641 13.3064V15.1648C15.6641 15.4185 15.4576 15.625 15.2039 15.625H13.3455C13.0219 15.625 12.7595 15.8873 12.7595 16.2109C12.7595 16.5345 13.0219 16.7969 13.3455 16.7969H15.2039C16.1038 16.7969 16.836 16.0647 16.836 15.1648Z" fill="#5D5D5D"/>
<path id="Vector_9" d="M0.0390625 10C0.0390625 10.3236 0.301406 10.5859 0.625 10.5859H19.375C19.6986 10.5859 19.9609 10.3236 19.9609 10C19.9609 9.67641 19.6986 9.41406 19.375 9.41406H0.625C0.301406 9.41406 0.0390625 9.67641 0.0390625 10Z" fill="#5D5D5D"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

-11
View File
@@ -1,11 +0,0 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.8383 0H15.0391C14.7155 0 14.4531 0.262344 14.4531 0.585938C14.4531 0.909531 14.7155 1.17188 15.0391 1.17188H17.8383C18.3841 1.17188 18.8281 1.61594 18.8281 2.16176V4.96094C18.8281 5.28453 19.0905 5.54688 19.4141 5.54688C19.7377 5.54688 20 5.28453 20 4.96094V2.16176C20 0.969766 19.0302 0 17.8383 0Z" fill="#5D5D5D"/>
<path d="M0.585938 5.54688C0.909531 5.54688 1.17188 5.28453 1.17188 4.96094V2.16176C1.17188 1.61594 1.61594 1.17188 2.16172 1.17188H4.96094C5.28453 1.17188 5.54688 0.909531 5.54688 0.585938C5.54688 0.262344 5.28453 0 4.96094 0H2.16172C0.969766 0 0 0.969766 0 2.16176V4.96094C0 5.28453 0.262344 5.54688 0.585938 5.54688Z" fill="#5D5D5D"/>
<path d="M4.96094 18.8281H2.16172C1.61594 18.8281 1.17188 18.3841 1.17188 17.8382V15.0391C1.17188 14.7155 0.909531 14.4531 0.585938 14.4531C0.262344 14.4531 0 14.7155 0 15.0391V17.8382C0 19.0302 0.969766 20 2.16172 20H4.96094C5.28453 20 5.54688 19.7377 5.54688 19.4141C5.54688 19.0905 5.28453 18.8281 4.96094 18.8281Z" fill="#5D5D5D"/>
<path d="M19.4141 14.4531C19.0905 14.4531 18.8281 14.7155 18.8281 15.0391V17.8382C18.8281 18.3841 18.3841 18.8281 17.8383 18.8281H15.0391C14.7155 18.8281 14.4531 19.0905 14.4531 19.4141C14.4531 19.7377 14.7155 20 15.0391 20H17.8383C19.0303 20 20 19.0302 20 17.8382V15.0391C20 14.7155 19.7377 14.4531 19.4141 14.4531Z" fill="#5D5D5D"/>
<path d="M13.3455 4.29688H15.2039C15.4576 4.29688 15.6641 4.50332 15.6641 4.75711V6.61547C15.6641 6.93906 15.9264 7.20141 16.25 7.20141C16.5736 7.20141 16.836 6.93906 16.836 6.61547V4.75711C16.836 3.85715 16.1038 3.125 15.2039 3.125H13.3455C13.0219 3.125 12.7595 3.38734 12.7595 3.71094C12.7595 4.03453 13.0219 4.29688 13.3455 4.29688Z" fill="#5D5D5D"/>
<path d="M3.16406 4.75711V6.61547C3.16406 6.93906 3.42641 7.20141 3.75 7.20141C4.07359 7.20141 4.33594 6.93906 4.33594 6.61547V4.75711C4.33594 4.50332 4.54242 4.29688 4.79617 4.29688H6.65457C6.97816 4.29688 7.24051 4.03453 7.24051 3.71094C7.24051 3.38734 6.97816 3.125 6.65457 3.125H4.79617C3.89625 3.125 3.16406 3.85715 3.16406 4.75711Z" fill="#5D5D5D"/>
<path d="M6.65457 15.625H4.79617C4.54238 15.625 4.33594 15.4185 4.33594 15.1648V13.3064C4.33594 12.9828 4.07359 12.7205 3.75 12.7205C3.42641 12.7205 3.16406 12.9828 3.16406 13.3064V15.1648C3.16406 16.0647 3.89625 16.7969 4.79617 16.7969H6.65457C6.97816 16.7969 7.24051 16.5345 7.24051 16.2109C7.24051 15.8873 6.97816 15.625 6.65457 15.625Z" fill="#5D5D5D"/>
<path d="M16.836 15.1648V13.3064C16.836 12.9828 16.5736 12.7205 16.25 12.7205C15.9264 12.7205 15.6641 12.9828 15.6641 13.3064V15.1648C15.6641 15.4185 15.4576 15.625 15.2039 15.625H13.3455C13.0219 15.625 12.7595 15.8873 12.7595 16.2109C12.7595 16.5345 13.0219 16.7969 13.3455 16.7969H15.2039C16.1038 16.7969 16.836 16.0647 16.836 15.1648Z" fill="#5D5D5D"/>
<path d="M0.0390625 10C0.0390625 10.3236 0.301406 10.5859 0.625 10.5859H19.375C19.6986 10.5859 19.9609 10.3236 19.9609 10C19.9609 9.67641 19.6986 9.41406 19.375 9.41406H0.625C0.301406 9.41406 0.0390625 9.67641 0.0390625 10Z" fill="#5D5D5D"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

+24 -29
View File
@@ -33,14 +33,14 @@ class NavCubit extends Cubit<NavState> {
),
],
'Devices': [
IconButton(
icon: Image.asset(
Assets.iconsFilter,
height: 20,
width: 20,
),
onPressed: () {},
),
// IconButton(
// icon: Image.asset(
// Assets.iconsFilter,
// height: 20,
// width: 20,
// ),
// onPressed: () {},
// ),
IconButton(
icon: const Icon(
Icons.add,
@@ -65,14 +65,14 @@ class NavCubit extends Cubit<NavState> {
),
],
'Routine': [
IconButton(
icon: Image.asset(
Assets.iconsFilter,
height: 20,
width: 20,
),
onPressed: () {},
),
// IconButton(
// icon: Image.asset(
// Assets.iconsFilter,
// height: 20,
// width: 20,
// ),
// onPressed: () {},
// ),
IconButton(
icon: const Icon(
Icons.add,
@@ -98,16 +98,8 @@ class NavCubit extends Cubit<NavState> {
],
'Menu': [
IconButton(
icon: Image.asset(
Assets.iconsQrScan,
height: 20,
width: 20,
),
onPressed: () {},
),
IconButton(
icon: Image.asset(
Assets.iconsSettings,
icon: SvgPicture.asset(
Assets.iconsScan,
height: 20,
width: 20,
),
@@ -147,11 +139,14 @@ class NavCubit extends Cubit<NavState> {
const MenuView(),
];
Widget get currentPage => NavCubit().pages[pageIndex];
final PageController pageController = PageController();
void updatePageIndex(int index, BuildContext context) {
emit(NavChangePage());
void updatePageIndex(int index) {
pageIndex = index;
print('index: $index');
pageController.animateToPage(index,
duration: const Duration(milliseconds: 150), curve: Curves.easeIn);
emit(NavChangePage());
}
}
@@ -14,19 +14,24 @@ class AppBody extends StatelessWidget {
return BlocBuilder<NavCubit, NavState>(
builder: (context, state) {
return Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.imagesBackground,
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.imagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: NavCubit.of(context).currentPage,
);
child: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: NavCubit.of(context).pageController,
children: NavCubit.of(context).pages,
)
// NavCubit.of(context).currentPage,
);
},
);
}
@@ -19,6 +19,7 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
child: AppBar(
backgroundColor: Colors.transparent,
leadingWidth: 150,
toolbarHeight: Constants.appBarHeight,
leading: NavCubit.appBarLeading[
NavCubit().bottomNavItems[NavCubit.pageIndex].label],
actions: NavCubit.appBarActions[
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/nav_cubit.dart';
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
@@ -20,10 +21,13 @@ class DefaultNavBar extends StatelessWidget {
child: BottomNavigationBar(
backgroundColor: Colors.transparent,
onTap: (int index) {
cubit.updatePageIndex(index, context);
cubit.updatePageIndex(index);
if (DevicesCubit.get(context).chosenCategoryView != null) {
DevicesCubit().clearCategoriesSelection(context);
}
if (SpacesCubit.get(context).selectedRoom != null) {
SpacesCubit.get(context).unselectRoom();
}
},
currentIndex: NavCubit.pageIndex,
selectedItemColor: ColorsManager.primaryColor,
+17 -1
View File
@@ -2,11 +2,13 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
import 'package:syncrow_app/features/auth/model/token.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/services/api/authentication_api.dart';
import 'package:syncrow_app/services/api/network_exception.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
part 'auth_state.dart';
@@ -50,7 +52,10 @@ class AuthCubit extends Cubit<AuthState> {
);
if (token.accessTokenIsNotEmpty) {
//Map dictionary
FlutterSecureStorage storage = const FlutterSecureStorage();
await storage.write(
key: Constants.tokenAccessKey, value: token.accessToken);
user = UserModel.fromToken(token);
emit(AuthSuccess());
} else {
@@ -60,4 +65,15 @@ class AuthCubit extends Cubit<AuthState> {
throw ServerFailure.fromDioError(e);
}
}
logout() async {
emit(AuthLoading());
try {
FlutterSecureStorage storage = const FlutterSecureStorage();
await storage.delete(key: Constants.tokenAccessKey);
emit(AuthLoggedOut());
} on DioException catch (e) {
throw ServerFailure.fromDioError(e);
}
}
}
+2
View File
@@ -16,6 +16,8 @@ class AuthError extends AuthState {
class AuthSuccess extends AuthState {}
class AuthLoggedOut extends AuthState {}
class AuthPasswordVisibilityChanged extends AuthState {}
class AuthAgreeToTermsChanged extends AuthState {}
+1 -1
View File
@@ -49,7 +49,7 @@ class UserModel {
Map<String, dynamic> tempJson = token.decodeToken();
return UserModel(
id: tempJson['userId'].toString(),
id: tempJson['uuid'].toString(),
email: tempJson['email'],
name: null,
photoUrl: null,
@@ -263,6 +263,15 @@ class DevicesCubit extends Cubit<DevicesState> {
return null;
}
DevicesCategoryModel? get chosenCategory {
for (var category in allCategories) {
if (category.isSelected) {
return category;
}
}
return null;
}
selectDevice(DeviceModel device) {
for (var category in allCategories) {
for (var device in category.devices) {
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/ac_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import '../../../../../generated/assets.dart';
@@ -38,7 +38,7 @@ class ACsView extends StatelessWidget {
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: DefaultAppBar(context),
appBar: const CategoryViewAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/display_medium.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import '../../../../../utils/resource_manager/color_manager.dart';
class CategoryViewAppBar extends StatelessWidget
implements PreferredSizeWidget {
const CategoryViewAppBar({
super.key,
});
@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
toolbarHeight: Constants.appBarHeight,
centerTitle: true,
title: DisplayMedium(
text: DevicesCubit.get(context).chosenCategory!.name,
style: context.displayMedium.copyWith(
color: ColorsManager.primaryColor,
fontWeight: FontWeight.bold,
),
),
leading: IconButton(
icon: const Icon(
Icons.arrow_back_ios,
color: ColorsManager.textPrimaryColor,
),
onPressed: () {
DevicesCubit.get(context).clearCategoriesSelection(context);
},
),
);
}
@override
Size get preferredSize => Size.fromHeight(Constants.appBarHeight);
}
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
import 'package:syncrow_app/features/devices/bloc/curtains/curtains_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_list.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -30,7 +30,7 @@ class CurtainView extends StatelessWidget {
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: DefaultAppBar(context),
appBar: const CategoryViewAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
@@ -65,12 +65,10 @@ class DevicesViewBody extends StatelessWidget {
SpacesCubit.get(context).devicesPageController,
count: 3,
effect: const WormEffect(
paintStyle: PaintingStyle.stroke,
dotHeight: 8,
dotWidth: 8,
),
onDotClicked: (index) {
SpacesCubit.get(context).unselectRoom();
},
),
),
],
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view_list.dart';
import '../../../../../generated/assets.dart';
import '../../../../../utils/resource_manager/color_manager.dart';
import '../../../../app_layout/view/widgets/default_app_bar.dart';
import '../../../bloc/devices_cubit.dart';
import '../../../bloc/lights/lights_cubit.dart';
import '../../../model/light_model.dart';
@@ -43,7 +43,7 @@ class LightsView extends StatelessWidget {
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: DefaultAppBar(context),
appBar: const CategoryViewAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
@@ -67,58 +67,6 @@ class RoomsSlider extends StatelessWidget {
],
),
);
// SingleChildScrollView(
// controller: SpacesCubit.get(context).roomsScrollController,
// scrollDirection: Axis.horizontal,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15),
// child: InkWell(
// onTap: () {
// SpacesCubit.get(context).unselectRoom();
// },
// child: TitleMedium(
// text: StringsManager.wizard,
// style: context.titleMedium.copyWith(
// fontSize: 25,
// color: SpacesCubit.get(context).selectedRoom == null
// ? ColorsManager.textPrimaryColor
// : ColorsManager.textPrimaryColor.withOpacity(.2),
// ),
// ),
// ),
// ),
// ...SpacesCubit.get(context).selectedSpace.rooms.map(
// (room) => Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15),
// child: InkWell(
// onTap: () {
// SpacesCubit.get(context).selectRoom(room);
// },
// child: TitleMedium(
// text: room.name,
// style: context.titleMedium.copyWith(
// fontSize: 25,
// color: SpacesCubit.get(context).selectedRoomIndex ==
// SpacesCubit.get(context)
// .selectedSpace
// .rooms
// .indexOf(room) +
// 1
// ? ColorsManager.textPrimaryColor
// : ColorsManager.textPrimaryColor
// .withOpacity(.2),
// ),
// ),
// ),
// ),
// )
// ],
// ),
// );
},
);
}
+54 -19
View File
@@ -1,8 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/menu/bloc/menu_cubit.dart';
import 'package:syncrow_app/features/menu/view/widgets/menu_list.dart';
import 'package:syncrow_app/features/menu/view/widgets/profile_tab.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class MenuView extends StatelessWidget {
@@ -14,26 +19,56 @@ class MenuView extends StatelessWidget {
create: (BuildContext context) => MenuCubit(),
child: BlocBuilder<MenuCubit, MenuState>(
builder: (context, state) {
return Padding(
padding: EdgeInsets.only(
top: Constants.appBarHeight,
bottom: Constants.bottomNavBarHeight,
left: Constants.defaultPadding,
right: Constants.defaultPadding,
),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
const ProfileTab(),
...MenuCubit.of(context).menuLists.map(
(list) => MenuList(
listModel: list,
),
return BlocBuilder<AuthCubit, AuthState>(
builder: (context, state) {
return Padding(
padding: EdgeInsets.only(
top: Constants.appBarHeight,
bottom: Constants.bottomNavBarHeight,
left: Constants.defaultPadding,
right: Constants.defaultPadding,
),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
const ProfileTab(),
...MenuCubit.of(context).menuLists.map(
(list) => MenuList(
listModel: list,
),
),
const SizedBox(
height: 15,
),
],
),
),
InkWell(
onTap: () {
AuthCubit.get(context).logout();
Navigator.of(context).pushNamedAndRemoveUntil(
Routes.authLogin, (route) => false);
},
child: Row(
children: [
Expanded(
child: DefaultContainer(
child: Center(
child: BodyLarge(
text: 'Logout',
style: context.bodyLarge.copyWith(
color: Colors.red,
),
),
),
),
),
],
),
)
],
),
),
);
},
);
},
),
@@ -13,6 +13,8 @@ class DefaultButton extends StatelessWidget {
this.isDone = false,
this.customTextStyle,
this.customButtonStyle,
this.backgroundColor,
this.foregroundColor,
});
final void Function()? onPressed;
@@ -29,6 +31,10 @@ class DefaultButton extends StatelessWidget {
final ButtonStyle? customButtonStyle;
final Color? backgroundColor;
final Color? foregroundColor;
@override
Widget build(BuildContext context) {
return ElevatedButton(
@@ -41,17 +47,22 @@ class DefaultButton extends StatelessWidget {
customTextStyle ??
context.bodyMedium.copyWith(
fontSize: 16,
color: foregroundColor,
),
),
foregroundColor: MaterialStateProperty.all(
isSecondary
? Colors.black
: enabled
? Colors.white
? foregroundColor ?? Colors.white
: Colors.black,
),
backgroundColor: MaterialStateProperty.all(
enabled ? ColorsManager.primaryColor : Colors.grey),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return enabled
? backgroundColor ?? ColorsManager.primaryColor
: Colors.grey;
}),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
+12 -9
View File
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class SplashView extends StatelessWidget {
const SplashView({super.key});
@@ -9,15 +11,16 @@ class SplashView extends StatelessWidget {
@override
Widget build(BuildContext context) {
//TODO remove this delay
Future.delayed(
const Duration(seconds: 5),
() {
Navigator.popAndPushNamed(
context,
Routes.authLogin,
);
},
);
Future.value().then((value) async {
var isLoggedIn = await const FlutterSecureStorage()
.read(key: Constants.tokenAccessKey) !=
null;
if (isLoggedIn) {
Navigator.pushReplacementNamed(context, Routes.homeRoute);
} else {
Navigator.pushReplacementNamed(context, Routes.authLogin);
}
});
return Scaffold(
body: Stack(
alignment: Alignment.center,
+1 -2
View File
@@ -2,7 +2,6 @@
class Assets {
Assets._();
static const String assetsIconsQrScan = 'assets/icons/qr_scan.svg';
static const String assetsIconsSettings = 'assets/icons/settings.svg';
static const String fontsAftikaRegular = 'assets/fonts/AftikaRegular.ttf';
static const String iconsAC = 'assets/icons/AC.svg';
@@ -38,9 +37,9 @@ class Assets {
static const String iconsMenuFill = 'assets/icons/Menu-fill.svg';
static const String iconsMinus = 'assets/icons/minus.svg';
static const String iconsPlus = 'assets/icons/plus.svg';
static const String iconsQrScan = 'assets/icons/qr_scan.png';
static const String iconsRoutines = 'assets/icons/Routines.svg';
static const String iconsRoutinesFill = 'assets/icons/Routines-fill.svg';
static const String iconsScan = 'assets/icons/Scan.svg';
static const String iconsScreen = 'assets/icons/Screen.svg';
static const String iconsSettings = 'assets/icons/settings.png';
static const String iconsSummer = 'assets/icons/Summer.svg';
+9
View File
@@ -2,9 +2,11 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart';
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'my_app.dart';
@@ -32,6 +34,13 @@ void main() {
//to initialize the locator
initialSetup();
//final SharedPreferences prefs = await SharedPreferences.getInstance();
// var isLoggedIn = (prefs.getBool('isLoggedIn') == null) ? false : prefs.getBool('isLoggedIn');
//
var storage = const FlutterSecureStorage();
bool isLoggedIn =
await (storage.read(key: Constants.tokenAccessKey)) != null;
//to save the locale in the shared preferences
await LocalizationService.saveLocale(const Locale("en", "AE"));
final savedLocale = await LocalizationService.savedLocale();
+2 -2
View File
@@ -4,14 +4,14 @@ abstract class Constants {
static const String countryCode = "US";
static const double appBarHeightPercentage = 0.1175;
static const double appBarHeightPercentage = 0.12;
static const double bottomNavBarHeightPercentage = 0.1175;
static late double appBarHeight;
static late double bottomNavBarHeight;
static const double defaultPadding = 16;
static const String tokenKey = 'userToken';
static const String tokenAccessKey = 'access_token';
}
enum DeviceType {