mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 23:44:55 +00:00
Modified Devices Pages
This commit is contained in:
@ -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,
|
||||
),
|
||||
@ -151,6 +143,7 @@ class NavCubit extends Cubit<NavState> {
|
||||
|
||||
void updatePageIndex(int index) {
|
||||
pageIndex = index;
|
||||
print('index: $index');
|
||||
pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 150), curve: Curves.easeIn);
|
||||
emit(NavChangePage());
|
||||
|
||||
@ -26,9 +26,7 @@ class AppBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: PageView(
|
||||
onPageChanged: (int index) {
|
||||
NavCubit.of(context).updatePageIndex(index);
|
||||
},
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: NavCubit.of(context).pageController,
|
||||
children: NavCubit.of(context).pages,
|
||||
)
|
||||
|
||||
@ -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';
|
||||
@ -24,6 +25,9 @@ class DefaultNavBar extends StatelessWidget {
|
||||
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,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ class AuthError extends AuthState {
|
||||
|
||||
class AuthSuccess extends AuthState {}
|
||||
|
||||
class AuthLoggedOut extends AuthState {}
|
||||
|
||||
class AuthPasswordVisibilityChanged extends AuthState {}
|
||||
|
||||
class AuthAgreeToTermsChanged extends AuthState {}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -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_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),
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user