mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
Modified Devices Pages
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
@ -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 |
@ -33,14 +33,14 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
'Devices': [
|
'Devices': [
|
||||||
IconButton(
|
// IconButton(
|
||||||
icon: Image.asset(
|
// icon: Image.asset(
|
||||||
Assets.iconsFilter,
|
// Assets.iconsFilter,
|
||||||
height: 20,
|
// height: 20,
|
||||||
width: 20,
|
// width: 20,
|
||||||
),
|
// ),
|
||||||
onPressed: () {},
|
// onPressed: () {},
|
||||||
),
|
// ),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add,
|
Icons.add,
|
||||||
@ -65,14 +65,14 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
'Routine': [
|
'Routine': [
|
||||||
IconButton(
|
// IconButton(
|
||||||
icon: Image.asset(
|
// icon: Image.asset(
|
||||||
Assets.iconsFilter,
|
// Assets.iconsFilter,
|
||||||
height: 20,
|
// height: 20,
|
||||||
width: 20,
|
// width: 20,
|
||||||
),
|
// ),
|
||||||
onPressed: () {},
|
// onPressed: () {},
|
||||||
),
|
// ),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add,
|
Icons.add,
|
||||||
@ -98,16 +98,8 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
],
|
],
|
||||||
'Menu': [
|
'Menu': [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Image.asset(
|
icon: SvgPicture.asset(
|
||||||
Assets.iconsQrScan,
|
Assets.iconsScan,
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Image.asset(
|
|
||||||
Assets.iconsSettings,
|
|
||||||
height: 20,
|
height: 20,
|
||||||
width: 20,
|
width: 20,
|
||||||
),
|
),
|
||||||
@ -151,6 +143,7 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
|
|
||||||
void updatePageIndex(int index) {
|
void updatePageIndex(int index) {
|
||||||
pageIndex = index;
|
pageIndex = index;
|
||||||
|
print('index: $index');
|
||||||
pageController.animateToPage(index,
|
pageController.animateToPage(index,
|
||||||
duration: const Duration(milliseconds: 150), curve: Curves.easeIn);
|
duration: const Duration(milliseconds: 150), curve: Curves.easeIn);
|
||||||
emit(NavChangePage());
|
emit(NavChangePage());
|
||||||
|
@ -26,9 +26,7 @@ class AppBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: PageView(
|
child: PageView(
|
||||||
onPageChanged: (int index) {
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
NavCubit.of(context).updatePageIndex(index);
|
|
||||||
},
|
|
||||||
controller: NavCubit.of(context).pageController,
|
controller: NavCubit.of(context).pageController,
|
||||||
children: NavCubit.of(context).pages,
|
children: NavCubit.of(context).pages,
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/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/features/devices/bloc/devices_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';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -24,6 +25,9 @@ class DefaultNavBar extends StatelessWidget {
|
|||||||
if (DevicesCubit.get(context).chosenCategoryView != null) {
|
if (DevicesCubit.get(context).chosenCategoryView != null) {
|
||||||
DevicesCubit().clearCategoriesSelection(context);
|
DevicesCubit().clearCategoriesSelection(context);
|
||||||
}
|
}
|
||||||
|
if (SpacesCubit.get(context).selectedRoom != null) {
|
||||||
|
SpacesCubit.get(context).unselectRoom();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
currentIndex: NavCubit.pageIndex,
|
currentIndex: NavCubit.pageIndex,
|
||||||
selectedItemColor: ColorsManager.primaryColor,
|
selectedItemColor: ColorsManager.primaryColor,
|
||||||
|
@ -2,11 +2,13 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/login_with_email_model.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/token.dart';
|
import 'package:syncrow_app/features/auth/model/token.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/user_model.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/authentication_api.dart';
|
||||||
import 'package:syncrow_app/services/api/network_exception.dart';
|
import 'package:syncrow_app/services/api/network_exception.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
part 'auth_state.dart';
|
part 'auth_state.dart';
|
||||||
|
|
||||||
@ -50,7 +52,10 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (token.accessTokenIsNotEmpty) {
|
if (token.accessTokenIsNotEmpty) {
|
||||||
//Map dictionary
|
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||||
|
await storage.write(
|
||||||
|
key: Constants.tokenAccessKey, value: token.accessToken);
|
||||||
|
|
||||||
user = UserModel.fromToken(token);
|
user = UserModel.fromToken(token);
|
||||||
emit(AuthSuccess());
|
emit(AuthSuccess());
|
||||||
} else {
|
} else {
|
||||||
@ -60,4 +65,15 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
throw ServerFailure.fromDioError(e);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ class AuthError extends AuthState {
|
|||||||
|
|
||||||
class AuthSuccess extends AuthState {}
|
class AuthSuccess extends AuthState {}
|
||||||
|
|
||||||
|
class AuthLoggedOut extends AuthState {}
|
||||||
|
|
||||||
class AuthPasswordVisibilityChanged extends AuthState {}
|
class AuthPasswordVisibilityChanged extends AuthState {}
|
||||||
|
|
||||||
class AuthAgreeToTermsChanged extends AuthState {}
|
class AuthAgreeToTermsChanged extends AuthState {}
|
||||||
|
@ -49,7 +49,7 @@ class UserModel {
|
|||||||
Map<String, dynamic> tempJson = token.decodeToken();
|
Map<String, dynamic> tempJson = token.decodeToken();
|
||||||
|
|
||||||
return UserModel(
|
return UserModel(
|
||||||
id: tempJson['userId'].toString(),
|
id: tempJson['uuid'].toString(),
|
||||||
email: tempJson['email'],
|
email: tempJson['email'],
|
||||||
name: null,
|
name: null,
|
||||||
photoUrl: null,
|
photoUrl: null,
|
||||||
|
@ -65,12 +65,10 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
SpacesCubit.get(context).devicesPageController,
|
SpacesCubit.get(context).devicesPageController,
|
||||||
count: 3,
|
count: 3,
|
||||||
effect: const WormEffect(
|
effect: const WormEffect(
|
||||||
|
paintStyle: PaintingStyle.stroke,
|
||||||
dotHeight: 8,
|
dotHeight: 8,
|
||||||
dotWidth: 8,
|
dotWidth: 8,
|
||||||
),
|
),
|
||||||
onDotClicked: (index) {
|
|
||||||
SpacesCubit.get(context).unselectRoom();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -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),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/bloc/menu_cubit.dart';
|
||||||
import 'package:syncrow_app/features/menu/view/widgets/menu_list.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/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';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
class MenuView extends StatelessWidget {
|
class MenuView extends StatelessWidget {
|
||||||
@ -14,26 +19,56 @@ class MenuView extends StatelessWidget {
|
|||||||
create: (BuildContext context) => MenuCubit(),
|
create: (BuildContext context) => MenuCubit(),
|
||||||
child: BlocBuilder<MenuCubit, MenuState>(
|
child: BlocBuilder<MenuCubit, MenuState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Padding(
|
return BlocBuilder<AuthCubit, AuthState>(
|
||||||
padding: EdgeInsets.only(
|
builder: (context, state) {
|
||||||
top: Constants.appBarHeight,
|
return Padding(
|
||||||
bottom: Constants.bottomNavBarHeight,
|
padding: EdgeInsets.only(
|
||||||
left: Constants.defaultPadding,
|
top: Constants.appBarHeight,
|
||||||
right: Constants.defaultPadding,
|
bottom: Constants.bottomNavBarHeight,
|
||||||
),
|
left: Constants.defaultPadding,
|
||||||
child: SingleChildScrollView(
|
right: Constants.defaultPadding,
|
||||||
physics: const BouncingScrollPhysics(),
|
),
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
children: [
|
physics: const BouncingScrollPhysics(),
|
||||||
const ProfileTab(),
|
child: Column(
|
||||||
...MenuCubit.of(context).menuLists.map(
|
children: [
|
||||||
(list) => MenuList(
|
const ProfileTab(),
|
||||||
listModel: list,
|
...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.isDone = false,
|
||||||
this.customTextStyle,
|
this.customTextStyle,
|
||||||
this.customButtonStyle,
|
this.customButtonStyle,
|
||||||
|
this.backgroundColor,
|
||||||
|
this.foregroundColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
final void Function()? onPressed;
|
final void Function()? onPressed;
|
||||||
@ -29,6 +31,10 @@ class DefaultButton extends StatelessWidget {
|
|||||||
|
|
||||||
final ButtonStyle? customButtonStyle;
|
final ButtonStyle? customButtonStyle;
|
||||||
|
|
||||||
|
final Color? backgroundColor;
|
||||||
|
|
||||||
|
final Color? foregroundColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
@ -41,17 +47,22 @@ class DefaultButton extends StatelessWidget {
|
|||||||
customTextStyle ??
|
customTextStyle ??
|
||||||
context.bodyMedium.copyWith(
|
context.bodyMedium.copyWith(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
color: foregroundColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
foregroundColor: MaterialStateProperty.all(
|
foregroundColor: MaterialStateProperty.all(
|
||||||
isSecondary
|
isSecondary
|
||||||
? Colors.black
|
? Colors.black
|
||||||
: enabled
|
: enabled
|
||||||
? Colors.white
|
? foregroundColor ?? Colors.white
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
),
|
),
|
||||||
backgroundColor: MaterialStateProperty.all(
|
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||||
enabled ? ColorsManager.primaryColor : Colors.grey),
|
(Set<MaterialState> states) {
|
||||||
|
return enabled
|
||||||
|
? backgroundColor ?? ColorsManager.primaryColor
|
||||||
|
: Colors.grey;
|
||||||
|
}),
|
||||||
shape: MaterialStateProperty.all(
|
shape: MaterialStateProperty.all(
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
class SplashView extends StatelessWidget {
|
class SplashView extends StatelessWidget {
|
||||||
const SplashView({super.key});
|
const SplashView({super.key});
|
||||||
@ -9,15 +11,16 @@ class SplashView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//TODO remove this delay
|
//TODO remove this delay
|
||||||
Future.delayed(
|
Future.value().then((value) async {
|
||||||
const Duration(seconds: 5),
|
var isLoggedIn = await const FlutterSecureStorage()
|
||||||
() {
|
.read(key: Constants.tokenAccessKey) !=
|
||||||
Navigator.popAndPushNamed(
|
null;
|
||||||
context,
|
if (isLoggedIn) {
|
||||||
Routes.authLogin,
|
Navigator.pushReplacementNamed(context, Routes.homeRoute);
|
||||||
);
|
} else {
|
||||||
},
|
Navigator.pushReplacementNamed(context, Routes.authLogin);
|
||||||
);
|
}
|
||||||
|
});
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
class Assets {
|
class Assets {
|
||||||
Assets._();
|
Assets._();
|
||||||
|
|
||||||
static const String assetsIconsQrScan = 'assets/icons/qr_scan.svg';
|
|
||||||
static const String assetsIconsSettings = 'assets/icons/settings.svg';
|
static const String assetsIconsSettings = 'assets/icons/settings.svg';
|
||||||
static const String fontsAftikaRegular = 'assets/fonts/AftikaRegular.ttf';
|
static const String fontsAftikaRegular = 'assets/fonts/AftikaRegular.ttf';
|
||||||
static const String iconsAC = 'assets/icons/AC.svg';
|
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 iconsMenuFill = 'assets/icons/Menu-fill.svg';
|
||||||
static const String iconsMinus = 'assets/icons/minus.svg';
|
static const String iconsMinus = 'assets/icons/minus.svg';
|
||||||
static const String iconsPlus = 'assets/icons/plus.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 iconsRoutines = 'assets/icons/Routines.svg';
|
||||||
static const String iconsRoutinesFill = 'assets/icons/Routines-fill.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 iconsScreen = 'assets/icons/Screen.svg';
|
||||||
static const String iconsSettings = 'assets/icons/settings.png';
|
static const String iconsSettings = 'assets/icons/settings.png';
|
||||||
static const String iconsSummer = 'assets/icons/Summer.svg';
|
static const String iconsSummer = 'assets/icons/Summer.svg';
|
||||||
|
@ -2,9 +2,11 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/services/locator.dart';
|
||||||
import 'package:syncrow_app/utils/bloc_observer.dart';
|
import 'package:syncrow_app/utils/bloc_observer.dart';
|
||||||
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
|
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
import 'my_app.dart';
|
import 'my_app.dart';
|
||||||
|
|
||||||
@ -32,6 +34,13 @@ void main() {
|
|||||||
//to initialize the locator
|
//to initialize the locator
|
||||||
initialSetup();
|
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
|
//to save the locale in the shared preferences
|
||||||
await LocalizationService.saveLocale(const Locale("en", "AE"));
|
await LocalizationService.saveLocale(const Locale("en", "AE"));
|
||||||
final savedLocale = await LocalizationService.savedLocale();
|
final savedLocale = await LocalizationService.savedLocale();
|
||||||
|
@ -11,7 +11,7 @@ abstract class Constants {
|
|||||||
|
|
||||||
static const double defaultPadding = 16;
|
static const double defaultPadding = 16;
|
||||||
|
|
||||||
static const String tokenKey = 'userToken';
|
static const String tokenAccessKey = 'access_token';
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DeviceType {
|
enum DeviceType {
|
||||||
|
Reference in New Issue
Block a user