diff --git a/lib/utils/style/app_text_styles.dart b/.env.dev similarity index 100% rename from lib/utils/style/app_text_styles.dart rename to .env.dev diff --git a/lib/utils/style/colors.dart b/.env.prod similarity index 100% rename from lib/utils/style/colors.dart rename to .env.prod diff --git a/lib/utils/style/themes.dart b/.env.staging similarity index 100% rename from lib/utils/style/themes.dart rename to .env.staging diff --git a/android/app/build.gradle b/android/app/build.gradle index b1fa484..c817c87 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -24,7 +24,7 @@ if (flutterVersionName == null) { android { namespace "com.example.syncrow_app" - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 34 ndkVersion flutter.ndkVersion compileOptions { diff --git a/assets/fonts/AftikaRegular.ttf b/assets/fonts/AftikaRegular.ttf new file mode 100644 index 0000000..5ca4dc5 Binary files /dev/null and b/assets/fonts/AftikaRegular.ttf differ diff --git a/assets/icons/Devices-fill.png b/assets/icons/Devices-fill.png new file mode 100644 index 0000000..9abef55 Binary files /dev/null and b/assets/icons/Devices-fill.png differ diff --git a/assets/icons/Devices.png b/assets/icons/Devices.png new file mode 100644 index 0000000..b8de335 Binary files /dev/null and b/assets/icons/Devices.png differ diff --git a/assets/icons/Layout-fill.png b/assets/icons/Layout-fill.png new file mode 100644 index 0000000..30435d4 Binary files /dev/null and b/assets/icons/Layout-fill.png differ diff --git a/assets/icons/Layout.png b/assets/icons/Layout.png new file mode 100644 index 0000000..7a07715 Binary files /dev/null and b/assets/icons/Layout.png differ diff --git a/assets/icons/Menu-fill.png b/assets/icons/Menu-fill.png new file mode 100644 index 0000000..3f079b2 Binary files /dev/null and b/assets/icons/Menu-fill.png differ diff --git a/assets/icons/Menu.png b/assets/icons/Menu.png new file mode 100644 index 0000000..1379ff6 Binary files /dev/null and b/assets/icons/Menu.png differ diff --git a/assets/icons/Routines-fill.png b/assets/icons/Routines-fill.png new file mode 100644 index 0000000..1df576e Binary files /dev/null and b/assets/icons/Routines-fill.png differ diff --git a/assets/icons/Routines.png b/assets/icons/Routines.png new file mode 100644 index 0000000..8d80229 Binary files /dev/null and b/assets/icons/Routines.png differ diff --git a/assets/icons/dashboard-fill.png b/assets/icons/dashboard-fill.png new file mode 100644 index 0000000..7b18c46 Binary files /dev/null and b/assets/icons/dashboard-fill.png differ diff --git a/assets/icons/dashboard.png b/assets/icons/dashboard.png new file mode 100644 index 0000000..2a457b2 Binary files /dev/null and b/assets/icons/dashboard.png differ diff --git a/assets/images/automation.jpg b/assets/images/automation.jpg new file mode 100644 index 0000000..23dc891 Binary files /dev/null and b/assets/images/automation.jpg differ diff --git a/lib/features/auth/auth_provider.dart b/lib/features/auth/auth_provider.dart deleted file mode 100644 index 4a7cc47..0000000 --- a/lib/features/auth/auth_provider.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:syncrow_app/features/auth/models/user_model.dart'; - -class AuthProvider extends ChangeNotifier { - // todo remove temp user - UserModel user = UserModel( - id: '1', - name: 'John Doe', - email: '', - photoUrl: '', - isAgreementAccepted: false, - isAnonymous: false, - isEmailVerified: false, - phoneNumber: '', - ); -} diff --git a/lib/features/auth/auth_view.dart b/lib/features/auth/auth_view.dart deleted file mode 100644 index c2b789b..0000000 --- a/lib/features/auth/auth_view.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; -import 'package:provider/provider.dart'; -import 'package:syncrow_app/features/home/widgets/syncrow_logo.dart'; -import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; -import 'package:syncrow_app/navigation/route_manager.dart'; - -import '../../navigation/routing_constants.dart'; -import 'auth_provider.dart'; - -class AuthPage extends StatelessWidget { - const AuthPage({super.key}); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => AuthProvider(), - builder: (context, child) => Scaffold( - body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 40.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - const Expanded(child: SizedBox()), - const SyncrowLogo(), - const Expanded(flex: 2, child: SizedBox()), - DefaultTextButton( - text: 'Login', - onPressed: () { - RouteManager().routerManagerPopAndPushNamed( - routeName: Routes.homeRoute, - context: context, - ); - }, - isPrimary: true, - ), - const Gap(15), - const DefaultTextButton(text: 'Sign Up'), - const Gap(20), - Center( - child: InkWell( - onTap: () {}, - child: const Text( - 'Try as a Guest', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - ), - const Gap(30), - ], - ), - ), - ), - ); - } -} diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart new file mode 100644 index 0000000..98fcf39 --- /dev/null +++ b/lib/features/auth/bloc/auth_cubit.dart @@ -0,0 +1,8 @@ +import 'package:bloc/bloc.dart'; +import 'package:meta/meta.dart'; + +part 'auth_state.dart'; + +class AuthCubit extends Cubit { + AuthCubit() : super(AuthInitial()); +} diff --git a/lib/features/auth/bloc/auth_state.dart b/lib/features/auth/bloc/auth_state.dart new file mode 100644 index 0000000..85a432a --- /dev/null +++ b/lib/features/auth/bloc/auth_state.dart @@ -0,0 +1,6 @@ +part of 'auth_cubit.dart'; + +@immutable +abstract class AuthState {} + +class AuthInitial extends AuthState {} diff --git a/lib/features/auth/models/user_model.dart b/lib/features/auth/model/user_model.dart similarity index 100% rename from lib/features/auth/models/user_model.dart rename to lib/features/auth/model/user_model.dart diff --git a/lib/features/auth/view/auth_view.dart b/lib/features/auth/view/auth_view.dart new file mode 100644 index 0000000..e71db14 --- /dev/null +++ b/lib/features/auth/view/auth_view.dart @@ -0,0 +1,19 @@ +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/auth/view/widgets/auth_view_body.dart'; + +class AuthView extends StatelessWidget { + const AuthView({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return const Scaffold( + body: AuthViewBody(), + ); + }, + ); + } +} diff --git a/lib/features/auth/view/widgets/auth_view_body.dart b/lib/features/auth/view/widgets/auth_view_body.dart new file mode 100644 index 0000000..ad603ed --- /dev/null +++ b/lib/features/auth/view/widgets/auth_view_body.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; +import 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart'; + +import '../../../../navigation/routing_constants.dart'; + +class AuthViewBody extends StatelessWidget { + const AuthViewBody({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 40.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Expanded(child: SizedBox()), + const SyncrowLogo(), + const Expanded(flex: 2, child: SizedBox()), + DefaultTextButton( + text: 'Login', + onPressed: () { + Navigator.popAndPushNamed(context, Routes.homeRoute); + }, + ), + const Gap(15), + const DefaultTextButton( + text: 'Sign Up', + isSecondary: true, + ), + const Gap(20), + Center( + child: InkWell( + onTap: () {}, + child: const Text( + 'Try as a Guest', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + ), + const Gap(30), + ], + ), + ); + } +} diff --git a/lib/features/dashboard/bloc/dashboard_cubit.dart b/lib/features/dashboard/bloc/dashboard_cubit.dart new file mode 100644 index 0000000..da13e50 --- /dev/null +++ b/lib/features/dashboard/bloc/dashboard_cubit.dart @@ -0,0 +1,9 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +part 'dashboard_state.dart'; + +class DashboardCubit extends Cubit { + DashboardCubit() : super(DashboardInitial()); + + static DashboardCubit of(context) => BlocProvider.of(context); +} diff --git a/lib/features/dashboard/bloc/dashboard_state.dart b/lib/features/dashboard/bloc/dashboard_state.dart new file mode 100644 index 0000000..12e988c --- /dev/null +++ b/lib/features/dashboard/bloc/dashboard_state.dart @@ -0,0 +1,5 @@ +part of 'dashboard_cubit.dart'; + +abstract class DashboardState {} + +class DashboardInitial extends DashboardState {} diff --git a/lib/features/dashboard/view/dashboard_view.dart b/lib/features/dashboard/view/dashboard_view.dart new file mode 100644 index 0000000..9c132b1 --- /dev/null +++ b/lib/features/dashboard/view/dashboard_view.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DashboardView extends StatelessWidget { + const DashboardView({super.key}); + + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} diff --git a/lib/features/home/home_provider.dart b/lib/features/home/bloc/home_cubit.dart similarity index 63% rename from lib/features/home/home_provider.dart rename to lib/features/home/bloc/home_cubit.dart index d753662..0d08783 100644 --- a/lib/features/home/home_provider.dart +++ b/lib/features/home/bloc/home_cubit.dart @@ -1,29 +1,31 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/features/home/model/device_model.dart'; -import 'package:syncrow_app/features/profile/profile_view.dart'; -import 'package:syncrow_app/features/scene/scene_view.dart'; -import 'package:syncrow_app/features/smart/smart_view.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; -import 'home_state.dart'; -import 'widgets/home_view_body.dart'; +import '../../profile/view/profile_view.dart'; +import '../../scene/view/scene_view.dart'; +import '../../smart/view/smart_view.dart'; +import '../model/device_model.dart'; +import '../view/widgets/home_view_body.dart'; -class HomeProvider extends ChangeNotifier { - HomeProvider() { - print('HomeProvider created'); +part 'home_state.dart'; + +class HomeCubit extends Cubit { + HomeCubit() : super(HomeInitial()) { getDevices(); } - HomeState state = HomeState(); + //TODO separate the navigation logic to another cubit + static HomeCubit get(context) => BlocProvider.of(context); static int pageIndex = 0; var devices = []; Future> getDevices() async { - state.setLoading(); + emit(HomeLoading()); await Future.delayed(const Duration(seconds: 2)); - state.setSuccess(); - notifyListeners(); + emit(HomeSuccess()); + return devices = []; } @@ -64,19 +66,15 @@ class HomeProvider extends ChangeNotifier { final List pages = [ const HomeViewBody(), - const ScenePage(), + const SceneView(), const SmartPage(), - const ProfilePage(), + const ProfileView(), ]; - Widget getCurrentPage() { - notifyListeners(); - - return pages[pageIndex]; - } + static Widget get currentPage => HomeCubit().pages[pageIndex]; void updatePageIndex(int index, BuildContext context) { + emit(HomeChangeIndex()); pageIndex = index; - notifyListeners(); } } diff --git a/lib/features/home/bloc/home_state.dart b/lib/features/home/bloc/home_state.dart new file mode 100644 index 0000000..fe73ce7 --- /dev/null +++ b/lib/features/home/bloc/home_state.dart @@ -0,0 +1,14 @@ +part of 'home_cubit.dart'; + +@immutable +abstract class HomeState {} + +class HomeInitial extends HomeState {} + +class HomeLoading extends HomeState {} + +class HomeSuccess extends HomeState {} + +class HomeFailure extends HomeState {} + +class HomeChangeIndex extends HomeState {} diff --git a/lib/features/home/home_state.dart b/lib/features/home/home_state.dart deleted file mode 100644 index 0f306ce..0000000 --- a/lib/features/home/home_state.dart +++ /dev/null @@ -1,28 +0,0 @@ -class HomeState { - HomeState() { - loading = false; - } - - late bool loading; - - late bool success; - late bool error; - - void setLoading() { - loading = true; - success = false; - error = false; - } - - void setSuccess() { - loading = false; - success = true; - error = false; - } - - void setError() { - loading = false; - success = false; - error = true; - } -} diff --git a/lib/features/home/home_view.dart b/lib/features/home/home_view.dart deleted file mode 100644 index 0f08283..0000000 --- a/lib/features/home/home_view.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../shared_widgets/default_nav_bar.dart'; -import 'home_provider.dart'; -import 'widgets/default_app_bar.dart'; - -class HomePage extends StatelessWidget { - const HomePage({super.key}); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => HomeProvider(), - builder: (context, child) => Consumer( - builder: (context, provider, child) { - return Scaffold( - appBar: const DefaultAppBar(), - body: provider.state.loading - ? const Center(child: CircularProgressIndicator()) - : provider.getCurrentPage(), - bottomNavigationBar: const DefaultNavBar(), - ); - }, - ), - ); - } -} diff --git a/lib/features/home/view/home_view.dart b/lib/features/home/view/home_view.dart new file mode 100644 index 0000000..6e565df --- /dev/null +++ b/lib/features/home/view/home_view.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/home/bloc/home_cubit.dart'; + +import '../../shared_widgets/default_app_bar.dart'; +import '../../shared_widgets/default_nav_bar.dart'; + +class HomeView extends StatelessWidget { + const HomeView({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => HomeCubit(), + child: BlocBuilder( + builder: (context, state) { + return Scaffold( + appBar: const DefaultAppBar(), + body: state is HomeLoading + ? const Center(child: CircularProgressIndicator()) + : HomeCubit.currentPage, + bottomNavigationBar: const DefaultNavBar(), + ); + }, + ), + ); + } +} diff --git a/lib/features/home/view/widgets/home_view_body.dart b/lib/features/home/view/widgets/home_view_body.dart new file mode 100644 index 0000000..83f7eea --- /dev/null +++ b/lib/features/home/view/widgets/home_view_body.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/home/bloc/home_cubit.dart'; + +import 'home_view_no_devices.dart'; + +class HomeViewBody extends StatelessWidget { + const HomeViewBody({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => HomeCubit(), + child: BlocBuilder( + builder: (context, state) { + return HomeCubit.get(context).devices.isEmpty + ? const HomeViewNoDevices() + : const SizedBox(); + }, + )); + } +} diff --git a/lib/features/home/view/widgets/home_view_no_devices.dart b/lib/features/home/view/widgets/home_view_no_devices.dart new file mode 100644 index 0000000..b597f4c --- /dev/null +++ b/lib/features/home/view/widgets/home_view_no_devices.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; +import 'package:syncrow_app/utils/resource_manager/assets_manager.dart'; + +class HomeViewNoDevices extends StatelessWidget { + const HomeViewNoDevices({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + ImageManager.boxEmpty, + opacity: const AlwaysStoppedAnimation(0.5), + scale: 1, + width: 140, + ), + const Gap(15), + const Text( + 'No Devices', + style: TextStyle( + color: Colors.grey, + fontSize: 18, + ), + ), + const Gap(15), + const DefaultTextButton( + text: 'Add Device', + ), + ], + ), + ); + } +} diff --git a/lib/features/home/widgets/home_view_body.dart b/lib/features/home/widgets/home_view_body.dart deleted file mode 100644 index b912d43..0000000 --- a/lib/features/home/widgets/home_view_body.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; -import 'package:provider/provider.dart'; -import 'package:syncrow_app/features/home/home_provider.dart'; -import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; -import 'package:syncrow_app/resource_manager/assets_manager.dart'; - -class HomeViewBody extends StatelessWidget { - const HomeViewBody({ - super.key, - }); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => HomeProvider(), - child: Consumer( - builder: (context, provider, child) { - return provider.devices.isEmpty - ? Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - ImageManager.boxEmpty, - opacity: const AlwaysStoppedAnimation(0.5), - scale: 1, - width: 140, - ), - const Gap(15), - const Text( - 'No Devices', - style: TextStyle( - color: Colors.grey, - fontSize: 18, - ), - ), - const Gap(15), - const DefaultTextButton( - text: 'Add Device', - isPrimary: true, - ), - ], - ), - ) - : const SizedBox(); - }, - ), - ); - } -} diff --git a/lib/features/profile/bloc/profile_cubit.dart b/lib/features/profile/bloc/profile_cubit.dart new file mode 100644 index 0000000..5748d7e --- /dev/null +++ b/lib/features/profile/bloc/profile_cubit.dart @@ -0,0 +1,8 @@ +import 'package:bloc/bloc.dart'; +import 'package:meta/meta.dart'; + +part 'profile_state.dart'; + +class ProfileCubit extends Cubit { + ProfileCubit() : super(ProfileInitial()); +} diff --git a/lib/features/profile/bloc/profile_state.dart b/lib/features/profile/bloc/profile_state.dart new file mode 100644 index 0000000..471c7d5 --- /dev/null +++ b/lib/features/profile/bloc/profile_state.dart @@ -0,0 +1,6 @@ +part of 'profile_cubit.dart'; + +@immutable +abstract class ProfileState {} + +class ProfileInitial extends ProfileState {} diff --git a/lib/features/profile/profile_provider.dart b/lib/features/profile/profile_provider.dart deleted file mode 100644 index fbf17fc..0000000 --- a/lib/features/profile/profile_provider.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'profile_state.dart'; - -class ProfileProvider extends ChangeNotifier { - final state = ProfileState(); -} diff --git a/lib/features/profile/profile_state.dart b/lib/features/profile/profile_state.dart deleted file mode 100644 index 77b6db4..0000000 --- a/lib/features/profile/profile_state.dart +++ /dev/null @@ -1,6 +0,0 @@ -class ProfileState { - - ProfileState() { - // init some variables - } -} diff --git a/lib/features/profile/profile_view.dart b/lib/features/profile/profile_view.dart deleted file mode 100644 index 1e3ce43..0000000 --- a/lib/features/profile/profile_view.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import 'profile_provider.dart'; - -class ProfilePage extends StatelessWidget { - const ProfilePage({super.key}); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => ProfileProvider(), - builder: (context, child) => const Center( - child: Text('Profile Page'), - ), - ); - } -} diff --git a/lib/features/profile/view/profile_view.dart b/lib/features/profile/view/profile_view.dart new file mode 100644 index 0000000..cde2cd5 --- /dev/null +++ b/lib/features/profile/view/profile_view.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/profile/bloc/profile_cubit.dart'; + +class ProfileView extends StatelessWidget { + const ProfileView({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => ProfileCubit(), + child: BlocBuilder( + builder: (context, state) { + return const Center( + child: Text('Profile Page'), + ); + }, + ), + ); + } +} diff --git a/lib/features/scene/bloc/scene_cubit.dart b/lib/features/scene/bloc/scene_cubit.dart new file mode 100644 index 0000000..0e4903b --- /dev/null +++ b/lib/features/scene/bloc/scene_cubit.dart @@ -0,0 +1,22 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:meta/meta.dart'; +import 'package:syncrow_app/features/scene/model/scene_model.dart'; + +part 'scene_state.dart'; + +class SceneCubit extends Cubit { + SceneCubit() : super(SceneInitial()) { + getScenes(); + } + + static SceneCubit of(context) => BlocProvider.of(context); + + void getScenes() { + emit(SceneLoading()); + Future.delayed(const Duration(seconds: 5), () { + emit(SceneSuccess()); + }); + } + + var scenes = []; +} diff --git a/lib/features/scene/bloc/scene_state.dart b/lib/features/scene/bloc/scene_state.dart new file mode 100644 index 0000000..5dce08c --- /dev/null +++ b/lib/features/scene/bloc/scene_state.dart @@ -0,0 +1,12 @@ +part of 'scene_cubit.dart'; + +@immutable +abstract class SceneState {} + +class SceneInitial extends SceneState {} + +class SceneLoading extends SceneState {} + +class SceneSuccess extends SceneState {} + +class SceneFailure extends SceneState {} diff --git a/lib/features/scene/model/scene_model.dart b/lib/features/scene/model/scene_model.dart new file mode 100644 index 0000000..f360ec2 --- /dev/null +++ b/lib/features/scene/model/scene_model.dart @@ -0,0 +1,46 @@ +class SceneModel { + final String id; + final String name; + final String description; + final String imageUrl; + final String location; + final String type; + final String rating; + final String price; + final String duration; + final String date; + final String time; + final String status; + + SceneModel({ + required this.id, + required this.name, + required this.description, + required this.imageUrl, + required this.location, + required this.type, + required this.rating, + required this.price, + required this.duration, + required this.date, + required this.time, + required this.status, + }); + + factory SceneModel.fromJson(Map json) { + return SceneModel( + id: json['id'], + name: json['name'], + description: json['description'], + imageUrl: json['imageUrl'], + location: json['location'], + type: json['type'], + rating: json['rating'], + price: json['price'], + duration: json['duration'], + date: json['date'], + time: json['time'], + status: json['status'], + ); + } +} diff --git a/lib/features/scene/scene_provider.dart b/lib/features/scene/scene_provider.dart deleted file mode 100644 index 152ce71..0000000 --- a/lib/features/scene/scene_provider.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'scene_state.dart'; - -class SceneProvider extends ChangeNotifier { - final state = SceneState(); -} diff --git a/lib/features/scene/scene_state.dart b/lib/features/scene/scene_state.dart deleted file mode 100644 index 50d0764..0000000 --- a/lib/features/scene/scene_state.dart +++ /dev/null @@ -1,6 +0,0 @@ -class SceneState { - - SceneState() { - // init some variables - } -} diff --git a/lib/features/scene/scene_view.dart b/lib/features/scene/scene_view.dart deleted file mode 100644 index bf4e920..0000000 --- a/lib/features/scene/scene_view.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import 'scene_provider.dart'; - -class ScenePage extends StatelessWidget { - const ScenePage({super.key}); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => SceneProvider(), - builder: (context, child) => const Center( - child: Text('Scene Page'), - ), - ); - } -} diff --git a/lib/features/scene/view/scene_view.dart b/lib/features/scene/view/scene_view.dart new file mode 100644 index 0000000..faa8284 --- /dev/null +++ b/lib/features/scene/view/scene_view.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/scene/bloc/scene_cubit.dart'; +import 'package:syncrow_app/features/scene/view/widgets/scene_view_no_scenes.dart'; + +class SceneView extends StatelessWidget { + const SceneView({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => SceneCubit(), + child: BlocBuilder( + builder: (context, state) { + return state is SceneLoading + ? const Center(child: CircularProgressIndicator()) + : const SceneViewNoScenes(); + }, + ), + ); + } +} diff --git a/lib/features/scene/view/widgets/scene_view_no_scenes.dart b/lib/features/scene/view/widgets/scene_view_no_scenes.dart new file mode 100644 index 0000000..5b8c90b --- /dev/null +++ b/lib/features/scene/view/widgets/scene_view_no_scenes.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; +import 'package:syncrow_app/utils/resource_manager/assets_manager.dart'; + +class SceneViewNoScenes extends StatelessWidget { + const SceneViewNoScenes({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 40), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + ImageManager.automation, + scale: 1, + opacity: const AlwaysStoppedAnimation(.5), + width: 140, + ), + const Gap(15), + const Text( + 'Home automation saves your time and effort by automating routine tasks.', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.grey), + ), + const Gap(20), + const DefaultTextButton( + text: 'Create Scene', + ) + ], + ), + ), + ); + } +} diff --git a/lib/features/home/widgets/default_app_bar.dart b/lib/features/shared_widgets/default_app_bar.dart similarity index 67% rename from lib/features/home/widgets/default_app_bar.dart rename to lib/features/shared_widgets/default_app_bar.dart index 4dfba41..518f82a 100644 --- a/lib/features/home/widgets/default_app_bar.dart +++ b/lib/features/shared_widgets/default_app_bar.dart @@ -1,17 +1,16 @@ import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:syncrow_app/features/home/widgets/syncrow_logo.dart'; -import 'package:syncrow_app/resource_manager/color_manager.dart'; - -import '../home_provider.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/home/bloc/home_cubit.dart'; +import 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget { const DefaultAppBar({super.key}); @override Widget build(BuildContext context) { - return Consumer( - builder: (context, provider, child) { + return BlocBuilder( + builder: (context, state) { return AppBar( title: const SyncrowLogo(), actions: [ diff --git a/lib/features/shared_widgets/default_nav_bar.dart b/lib/features/shared_widgets/default_nav_bar.dart index ec49627..8d3068f 100644 --- a/lib/features/shared_widgets/default_nav_bar.dart +++ b/lib/features/shared_widgets/default_nav_bar.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../home/home_provider.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/home/bloc/home_cubit.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class DefaultNavBar extends StatelessWidget { const DefaultNavBar({ @@ -10,15 +10,19 @@ class DefaultNavBar extends StatelessWidget { @override Widget build(BuildContext context) { - return Consumer( - builder: (context, provider, child) { + return BlocBuilder( + builder: (context, state) { return BottomNavigationBar( - onTap: (int index) => provider.updatePageIndex(index, context), - currentIndex: HomeProvider.pageIndex, - selectedItemColor: Colors.black, + onTap: (int index) => + HomeCubit.get(context).updatePageIndex(index, context), + currentIndex: HomeCubit.pageIndex, + selectedItemColor: ColorsManager.primaryColor, + selectedLabelStyle: const TextStyle( + color: ColorsManager.primaryColor, + ), unselectedItemColor: Colors.grey, elevation: 10, - items: provider.bottomNavItems, + items: HomeCubit.get(context).bottomNavItems, ); }, ); diff --git a/lib/features/shared_widgets/default_text_button.dart b/lib/features/shared_widgets/default_text_button.dart index 065af0c..6ee35de 100644 --- a/lib/features/shared_widgets/default_text_button.dart +++ b/lib/features/shared_widgets/default_text_button.dart @@ -1,25 +1,25 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/resource_manager/color_manager.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class DefaultTextButton extends StatelessWidget { const DefaultTextButton({ super.key, this.onPressed, required this.text, - this.isPrimary = false, + this.isSecondary = false, }); final void Function()? onPressed; final String text; - - final bool isPrimary; + final bool isSecondary; @override Widget build(BuildContext context) { return TextButton( onPressed: onPressed, - style: isPrimary - ? ButtonStyle( + style: isSecondary + ? null + : ButtonStyle( backgroundColor: MaterialStateProperty.all(ColorsManager.primaryColor), shape: MaterialStateProperty.all( @@ -27,11 +27,10 @@ class DefaultTextButton extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), ), - ) - : null, + ), child: Text( text, - style: TextStyle(color: isPrimary ? Colors.white : Colors.black), + style: TextStyle(color: isSecondary ? Colors.black : Colors.white), ), ); } diff --git a/lib/features/home/widgets/syncrow_logo.dart b/lib/features/shared_widgets/syncrow_logo.dart similarity index 84% rename from lib/features/home/widgets/syncrow_logo.dart rename to lib/features/shared_widgets/syncrow_logo.dart index e091f23..61fcc04 100644 --- a/lib/features/home/widgets/syncrow_logo.dart +++ b/lib/features/shared_widgets/syncrow_logo.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/resource_manager/assets_manager.dart'; +import 'package:syncrow_app/utils/resource_manager/assets_manager.dart'; class SyncrowLogo extends StatelessWidget { const SyncrowLogo({ diff --git a/lib/features/smart/bloc/smart_cubit.dart b/lib/features/smart/bloc/smart_cubit.dart new file mode 100644 index 0000000..272b6bf --- /dev/null +++ b/lib/features/smart/bloc/smart_cubit.dart @@ -0,0 +1,8 @@ +import 'package:bloc/bloc.dart'; +import 'package:meta/meta.dart'; + +part 'smart_state.dart'; + +class SmartCubit extends Cubit { + SmartCubit() : super(SmartInitial()); +} diff --git a/lib/features/smart/bloc/smart_state.dart b/lib/features/smart/bloc/smart_state.dart new file mode 100644 index 0000000..612fcf6 --- /dev/null +++ b/lib/features/smart/bloc/smart_state.dart @@ -0,0 +1,6 @@ +part of 'smart_cubit.dart'; + +@immutable +abstract class SmartState {} + +class SmartInitial extends SmartState {} diff --git a/lib/features/smart/smart_provider.dart b/lib/features/smart/smart_provider.dart deleted file mode 100644 index 02a82c9..0000000 --- a/lib/features/smart/smart_provider.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'smart_state.dart'; - -class SmartProvider extends ChangeNotifier { - final state = SmartState(); -} diff --git a/lib/features/smart/smart_state.dart b/lib/features/smart/smart_state.dart deleted file mode 100644 index c3cec9a..0000000 --- a/lib/features/smart/smart_state.dart +++ /dev/null @@ -1,6 +0,0 @@ -class SmartState { - - SmartState() { - // init some variables - } -} diff --git a/lib/features/smart/smart_view.dart b/lib/features/smart/smart_view.dart deleted file mode 100644 index 0abdfbe..0000000 --- a/lib/features/smart/smart_view.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import 'smart_provider.dart'; - -class SmartPage extends StatelessWidget { - const SmartPage({super.key}); - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => SmartProvider(), - builder: (context, child) => const Center( - child: Text('Smart Page'), - ), - ); - } -} diff --git a/lib/features/smart/view/smart_view.dart b/lib/features/smart/view/smart_view.dart new file mode 100644 index 0000000..039126a --- /dev/null +++ b/lib/features/smart/view/smart_view.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/smart/bloc/smart_cubit.dart'; + +class SmartPage extends StatelessWidget { + const SmartPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => SmartCubit(), + child: BlocBuilder( + builder: (context, state) { + return const Center( + child: Text('Smart Page'), + ); + }, + )); + } +} diff --git a/lib/features/splash/splash_view.dart b/lib/features/splash/view/splash_view.dart similarity index 60% rename from lib/features/splash/splash_view.dart rename to lib/features/splash/view/splash_view.dart index 3342f2e..02c118d 100644 --- a/lib/features/splash/splash_view.dart +++ b/lib/features/splash/view/splash_view.dart @@ -1,30 +1,22 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/features/splash/user_agreement_dialog.dart'; -import 'package:syncrow_app/navigation/route_manager.dart'; +import 'package:syncrow_app/features/splash/view/widgets/user_agreement_dialog.dart'; import 'package:syncrow_app/navigation/routing_constants.dart'; -import 'package:syncrow_app/resource_manager/assets_manager.dart'; +import 'package:syncrow_app/utils/resource_manager/assets_manager.dart'; class SplashView extends StatelessWidget { const SplashView({super.key}); @override Widget build(BuildContext context) { - //TODO Remove delay - // Future.delayed(const Duration(seconds: 5), () { - // RouteManager().routerManagerPushUntil( - // context, - // routeName: Routes.homeRoute, - // ); - // }); return Scaffold( appBar: AppBar( actions: [ IconButton( icon: const Icon(Icons.arrow_forward), onPressed: () { - RouteManager().routerManagerPopAndPushNamed( - routeName: Routes.authRoute, - context: context, + Navigator.popAndPushNamed( + context, + Routes.authRoute, ); }, ), diff --git a/lib/features/splash/user_agreement_dialog.dart b/lib/features/splash/view/widgets/user_agreement_dialog.dart similarity index 96% rename from lib/features/splash/user_agreement_dialog.dart rename to lib/features/splash/view/widgets/user_agreement_dialog.dart index f942af5..a4c3dfc 100644 --- a/lib/features/splash/user_agreement_dialog.dart +++ b/lib/features/splash/view/widgets/user_agreement_dialog.dart @@ -19,11 +19,11 @@ class UserAgreementDialog extends StatelessWidget { onPressed: () { Navigator.of(context).pop(); }, - isPrimary: true, ), DefaultTextButton( text: 'I Disagree', onPressed: () => Navigator.of(context).pop(), + isSecondary: true, ), ], ); diff --git a/lib/helpers/constants.dart b/lib/helpers/constants.dart deleted file mode 100644 index 83ca77f..0000000 --- a/lib/helpers/constants.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:flutter_dotenv/flutter_dotenv.dart'; - -class URLConstants { - static String baseURL = dotenv.env['BASE_URL'] ?? ''; - static String helpCenterPageURL = dotenv.env['HELP_PAGE_URL'] ?? ''; - static String termsPageURL = dotenv.env['TERMS_PAGE_URL'] ?? ''; - static String privacyPageURL = dotenv.env['PRIVACY_PAGE_URL'] ?? ''; - static String iosPlayStore = dotenv.env['IOS_PLAY_STORE'] ?? ''; -} - -class KeyConstants { - static const String languageCode = "Language Code"; - static const String countryCode = "Country Code"; - static const String username = "User Name"; - static const String password = "Password"; - static const String userFullName = "User Full Name"; - static const String userImageURL = "User Image URL"; - static const String userType = "User Type"; - static const String accessToken = "Access Token"; - static const String refreshToken = "Refresh Token"; - static const String newToken = "new-token"; - static const String loginID = "Login ID"; - static const String faceIDSaved = "Face ID Saved"; - static const String userID = "User ID"; - static const String officeID = "Office ID"; - static const String showServerMessage = "Show Server Message"; - static String oneSignalAppId = dotenv.env['ONE_SIGNAL_ID'] ?? ''; - - //shared preferences keys - static const String isDemoFlag = "isDemo"; - static const String isOnboardingFlag = "isOnboarding"; - static const String userIdValue = "userId"; - static const String phoneNumber = "phone"; - static const String loginCounter = 'loginCounter'; - static const String notificationCounter = 'notificationCounter'; - static const String doNotShowAgain = 'doNotShowAgain'; - static const String sendPlayerId = 'sendPlayerId'; - static const String srmPhone = 'srmPhone'; - static const String paragraphTitle = 'title'; - static const String paragraphBody = 'body'; - static const String playerId = 'PlayerId'; - static const String addProperty = 'addProperty'; - static const String showNotificationSetting = 'showNotificationSetting'; - static const String numberOfCases = 'numberOfCases'; - static const String internetConnection = 'internetConnection'; - static const String lowValuation = 'lowValuation'; - static const String highValuation = 'highValuation'; - static const String finalValuation = 'finalValuation'; - static const String firstLaunch = 'firstLaunch'; - static const String onboardedFirstUnit = 'onboardedFirstUnit'; - static const String accountIds = 'accountIds'; - static const String utmSourceParameter = 'utmSource'; - static const String utmMediumParameter = 'utmMedium'; - static const String utmCampaignNameParameter = 'utmCampaign'; - static const String accountIsDeleted = 'accountIsDeleted'; - static const String firstTimeLaunch = 'firstTimeLaunch'; - static const String loggedOut = 'loggedOut'; -} - -class APIConstants { - static const String unitsList = "app/api/v2/units/listInfo"; - static const String onboardingUnitList = 'app/api/v2/units/onboardingunit'; - static const String events = "event/events"; - static const String paymentEvents = "event/payment"; - static const String tenancyEvents = "event/tenancy"; - static const String renewTenancyContract = "opportunity/renewal-service"; - static const String findNewTenant = "opportunity/newTenant-service"; - static const String loginWithChannel = 'auth/login-with-channel'; - static const String verifyPassCode = 'auth/validate-pass-code'; - static const String refreshToken = 'auth/refresh-token'; - static const String updateUserInfo = 'auth/update-user-info'; - static const String readUserInfo = 'auth/read-user-info'; - static const String getCountyCode = 'auth/get-country-code'; - static const String notificationToken = 'auth/set-notification-token'; - static const String logout = 'auth/logout'; - static const String deleteAccount = 'auth/self-delete-user'; - static const String profileAPI = 'app/api/v2/users/profile'; - static const String pmUnitsList = 'app/api/v2/service/manageproperty'; - static const String rentPropertyUnitsList = 'app/api/v2/service/rentproperty'; - static const String sellPropertyUnitsList = 'app/api/v2/service/sellproperty'; - static const String upfrontPropertyUnitsList = 'app/api/v2/service/upfrontRentlist'; - static const String sendPMrequest = 'opportunity/pm-service'; - static const String sendSellRequest = 'opportunity/sell-service'; - static const String sendRentRequest = 'opportunity/rent-service'; - static const String sendUpfrontRequest = 'opportunity/upfront-service'; - static const String sendBuyRequest = 'opportunity/buy-service'; - static const String documentsPresignedUrl = 'cases/doc-presigned-url'; - static const String addDocumentsRequest = 'cases/add-doc-service'; - static const String handoverRequest = 'opportunity/handedOver-service'; - static const String tenancyUpfrontRequest = 'opportunity/tenancy-upfront-service'; - static const String eventsTypes = 'event/types'; - - //Add Property APIs - static const String getSuggestionsLocations = 'avm/getSuggestedLocations'; - static const String getSuggestionsUnits = 'avm/getunitbyLocationIdAndUnitNumber'; - static const String addPropertyRequest = 'cases/add-property-service-request'; - static const String manualPrepareAddPropertyRequest = 'cases/prepare-add-property-service'; - static const String manualAddPropertyRequest = 'cases/add-property-manual-service'; - static const String addPropertyRequestV3 = 'cases/add-property-service'; - static const String getNeighborhoods = 'cases/neighbourhood-locations'; - static const String valuateProperty = 'cases/valuate-property'; - static const String purposes = 'cases/purposesList'; - //Portfolio API - static const String portfolio = 'app/api/v2/users/portfolio'; - static const String insights = 'app/api/v2/users/portfolioInsights'; -} - -class AuthenticationConstants { - static const platformName = 'platformName'; - static const productName = 'productName'; - static const localAuthenticationAttempts = 'localAuthenticationAttempts'; - static const localAuthenticationLastAttempt = 'localAuthenticationLastAttempt'; -} - -class MIMEConstants { - static const pdfMime = "application/pdf"; - static const pngMime = "image/png"; - static const jpgMime = "image/jpeg"; - static const tiffMime = "image/tiff"; -} - -class AppDateFormat { - static const dateFormat = 'd MMM, yyyy'; -} diff --git a/lib/helpers/snack_bar.dart b/lib/helpers/snack_bar.dart deleted file mode 100644 index 4c0bb03..0000000 --- a/lib/helpers/snack_bar.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:syncrow_app/services/navigation_service.dart'; - -class CustomSnackBar { - static displaySnackBar(String message) { - final key = NavigationService.snackbarKey; - if (key != null) { - final snackBar = SnackBar(content: Text(message)); - key.currentState?.clearSnackBars(); - key.currentState?.showSnackBar(snackBar); - } - } - - static greenSnackBar(String message) { - final key = NavigationService.snackbarKey; - BuildContext? currentContext = key?.currentContext; - if (key != null && currentContext != null) { - final snackBar = SnackBar( - padding: const EdgeInsets.all(16), - // backgroundColor: KeyperColors.onboardingPortfolioCasesNumberBG, - content: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - // Image.asset( - // ImageConstants.checkGreenRounded, - // width: 32, - // height: 32, - // ), - const SizedBox( - width: 8, - ), - Text( - message, - // style: Theme.of(currentContext) - // .textTheme - // .bodySmall! - // .copyWith(fontSize: 14, fontWeight: FontWeight.w500, color: KeyperColors.greyBody), - ) - ]), - ); - key.currentState?.showSnackBar(snackBar); - } - } -} diff --git a/lib/main.dart b/lib/main.dart index 9057223..45efa52 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/utils/bloc_observer.dart'; import 'my_app.dart'; void main() { + Bloc.observer = MyBlocObserver(); + //TODO: Uncomment // runZonedGuarded(() async { // const environment = // String.fromEnvironment('FLAVOR', defaultValue: 'production'); @@ -10,9 +14,6 @@ void main() { // // HttpOverrides.global = MyHttpOverrides(); // WidgetsFlutterBinding.ensureInitialized(); - // // if (Platform.isAndroid) { - // // await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); - // // } // LicenseRegistry.addLicense(() async* { // final license = // await rootBundle.loadString('assets/fonts/roboto/LICENSE.txt'); diff --git a/lib/my_app.dart b/lib/my_app.dart index ef84f8d..7cc8ed0 100644 --- a/lib/my_app.dart +++ b/lib/my_app.dart @@ -1,50 +1,44 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:provider/provider.dart'; -import 'package:syncrow_app/resource_manager/color_manager.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart'; +import 'package:syncrow_app/features/home/bloc/home_cubit.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; +import 'package:syncrow_app/utils/resource_manager/theme_manager.dart'; -import 'features/auth/auth_provider.dart'; import 'navigation/router.dart' as router; import 'navigation/routing_constants.dart'; -import 'services/navigation_service.dart'; -class MyApp extends StatefulWidget { +class MyApp extends StatelessWidget { final Locale locale; const MyApp(this.locale, {super.key}); - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { - const SystemUiOverlayStyle( - statusBarColor: Colors.transparent, + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => AuthCubit(), + ), + BlocProvider( + create: (context) => HomeCubit(), + ), + ], + child: MaterialApp( + debugShowCheckedModeBanner: false, + color: ColorsManager.primaryColor, + title: 'Syncrow App', + onGenerateRoute: router.Router.generateRoute, + initialRoute: Routes.splash, + themeMode: ThemeMode.system, + theme: myTheme, + supportedLocales: const [ + Locale('en', ''), // English, no country code + Locale('ar', ''), // Arabic, no country code + ], + // locale: locale, + locale: const Locale('en', ''), + ), ); - return ChangeNotifierProvider( - create: (context) => AuthProvider(), - child: MaterialApp( - debugShowCheckedModeBanner: false, - navigatorKey: NavigationService.navigatorKey, - scaffoldMessengerKey: NavigationService.snackbarKey, - color: ColorsManager.primaryColor, - title: 'Syncrow App', - onGenerateRoute: router.Router.generateRoute, - initialRoute: Routes.splash, - themeMode: ThemeMode.system, - supportedLocales: const [ - Locale('en', ''), // English, no country code - Locale('ar', ''), // Arabic, no country code - ], - // locale: locale, - locale: const Locale('en', ''), - )); } } diff --git a/lib/navigation/route_manager.dart b/lib/navigation/route_manager.dart deleted file mode 100644 index 03a49f9..0000000 --- a/lib/navigation/route_manager.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'routing_constants.dart'; - -class RouteManager { - List routesWithoutLogin = [ - Routes.homeRoute, - ]; - - List exclusionList = []; - - //TODO (to mohammad) add the context extension - routerManager({required String routeName, required BuildContext context}) { - Navigator.of(context).pushNamed(routeName); - } - - routerManagerPushUntil(BuildContext? context, {required String routeName}) { - if (context != null) { - Navigator.of(context) - .pushNamedAndRemoveUntil(routeName, (route) => false); - } - } - - routerManagerPopAndPushNamed( - {required String routeName, required BuildContext context}) { - Navigator.of(context).popAndPushNamed(routeName); - } -} diff --git a/lib/navigation/router.dart b/lib/navigation/router.dart index 0d3f949..ffe84d1 100644 --- a/lib/navigation/router.dart +++ b/lib/navigation/router.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/features/auth/auth_view.dart'; -import 'package:syncrow_app/features/home/home_view.dart'; -import 'package:syncrow_app/features/profile/profile_view.dart'; -import 'package:syncrow_app/features/scene/scene_view.dart'; -import 'package:syncrow_app/features/smart/smart_view.dart'; -import 'package:syncrow_app/features/splash/splash_view.dart'; +import 'package:syncrow_app/features/auth/view/auth_view.dart'; +import 'package:syncrow_app/features/home/view/home_view.dart'; +import 'package:syncrow_app/features/profile/view/profile_view.dart'; +import 'package:syncrow_app/features/scene/view/scene_view.dart'; +import 'package:syncrow_app/features/smart/view/smart_view.dart'; +import 'package:syncrow_app/features/splash/view/splash_view.dart'; import 'routing_constants.dart'; @@ -17,15 +17,15 @@ class Router { case Routes.homeRoute: return MaterialPageRoute( - builder: (_) => const HomePage(), settings: settings); + builder: (_) => const HomeView(), settings: settings); case Routes.profileRoute: return MaterialPageRoute( - builder: (_) => const ProfilePage(), settings: settings); + builder: (_) => const ProfileView(), settings: settings); case Routes.sceneRoute: return MaterialPageRoute( - builder: (_) => const ScenePage(), settings: settings); + builder: (_) => const SceneView(), settings: settings); case Routes.smartRoute: return MaterialPageRoute( @@ -33,7 +33,7 @@ class Router { case Routes.authRoute: return MaterialPageRoute( - builder: (_) => const AuthPage(), settings: settings); + builder: (_) => const AuthView(), settings: settings); default: return MaterialPageRoute( diff --git a/lib/resource_manager/font_manager.dart b/lib/resource_manager/font_manager.dart deleted file mode 100644 index b755e01..0000000 --- a/lib/resource_manager/font_manager.dart +++ /dev/null @@ -1,45 +0,0 @@ -// import 'dart:ui'; - -// /// # To add custom fonts to your application, add a fonts section here, -// /// # in this "flutter" section. Each entry in this list should have a -// /// # "family" key with the font family name, and a "fonts" key with a -// /// # list giving the asset and other descriptors for the font. For -// /// # example: -// /// -// /// fonts: -// /// - family:Montserrat -// /// fonts: -// /// - asset: assets/ fonts/Montserrat-Botd. ttf -// /// weight: 700 -// /// - asset: assets/ fonts/Montserrat-SemiB01d. ttf -// /// weight: 600 - -// class FontsManager { -// static const FontWeight light = FontWeight.w300; -// static const FontWeight regular = FontWeight.w400; -// static const FontWeight medium = FontWeight.w500; -// static const FontWeight semiBold = FontWeight.w600; -// static const FontWeight bold = FontWeight.w700; -// static const FontWeight extraBold = FontWeight.w800; -// static const FontWeight black = FontWeight.w900; - -// static const String fontFamily = 'Avenir'; -// } - -// class FontSize { -// static const double s12 = 12; -// static const double s10 = 10; -// static const double s14 = 14; -// static const double s16 = 16; -// static const double s18 = 18; -// static const double s20 = 20; -// static const double s21 = 21; -// static const double s22 = 22; -// static const double s24 = 24; -// static const double s25 = 25; -// static const double s26 = 26; -// static const double s28 = 28; -// static const double s30 = 30; -// static const double s35 = 35; -// static const double s48 = 48; -// } diff --git a/lib/resource_manager/routes_manager.dart b/lib/resource_manager/routes_manager.dart deleted file mode 100644 index 8469dee..0000000 --- a/lib/resource_manager/routes_manager.dart +++ /dev/null @@ -1,78 +0,0 @@ -// import 'package:flutter/material.dart'; - -// class RoutesManager { -// static const String home = '/'; -// static const String about = '/about'; -// static const String complains = '/complains'; -// static const String reg = '/register'; -// static const String limit = '/limit'; -// static const String services = '/services'; -// static const String agents = '/agent'; -// static const String contact = '/contact'; -// static const String merchList = '/merchList'; -// static const String parkAmman = '/park_amman'; -// static const String consumerProtection = '/consumerProtection'; -// static const String definitions = '/definitions'; -// static const String conditions = '/conditions'; -// static const String responsibilities = '/responsibilities'; -// static const String responsibilitiesCompany = '/responsibilitiesCompany'; -// static const String agentFinder = '/agent_finder'; -// static const String agentRequest = '/agent_request'; -// static const String ayaMap = '/aya_map'; -// } - -// class RouteGenerator { -// static Route getRoute(RouteSettings settings) { -// switch (settings.name) { -// case RoutesManager.home: -// return MaterialPageRoute(builder: (_) => const HomeView()); -// case RoutesManager.about: -// return MaterialPageRoute(builder: (_) => const AboutView()); -// case RoutesManager.complains: -// return MaterialPageRoute(builder: (_) => ComplainsView()); -// case RoutesManager.reg: -// return MaterialPageRoute(builder: (_) => const RegistrationView()); -// case RoutesManager.limit: -// return MaterialPageRoute(builder: (_) => const LimitsView()); -// case RoutesManager.services: -// return MaterialPageRoute(builder: (_) => const ServicesView()); -// case RoutesManager.agents: -// return MaterialPageRoute(builder: (_) => const AgentsView()); -// case RoutesManager.contact: -// return MaterialPageRoute(builder: (_) => const ContactUsView()); -// case RoutesManager.merchList: -// return MaterialPageRoute(builder: (_) => const MerchListView()); -// case RoutesManager.parkAmman: -// return MaterialPageRoute(builder: (_) => const ParkAmmanView()); -// case RoutesManager.consumerProtection: -// return MaterialPageRoute( -// builder: (_) => const ConsumerProtectionView(), -// ); -// case RoutesManager.definitions: -// return MaterialPageRoute(builder: (_) => const DefinitionsView()); -// case RoutesManager.conditions: -// return MaterialPageRoute(builder: (_) => const ConditionsView()); -// case RoutesManager.responsibilities: -// return MaterialPageRoute(builder: (_) => const ResponsibilitiesView()); -// case RoutesManager.responsibilitiesCompany: -// return MaterialPageRoute( -// builder: (_) => const ResponsibilitiesCompanyView(), -// ); -// case RoutesManager.agentFinder: -// return MaterialPageRoute(builder: (_) => AgentFinderView()); -// case RoutesManager.agentRequest: -// return MaterialPageRoute(builder: (_) => const AgentRequestView()); -// case RoutesManager.ayaMap: -// return MaterialPageRoute(builder: (_) => const AyaMapView()); -// default: -// return MaterialPageRoute(builder: (_) => const ErrorView()); -// } -// } - -// static Route unknownRoute() => -// MaterialPageRoute(builder: (_) => const ErrorView()); - -// static List> initialRoute() => [ -// MaterialPageRoute(builder: (_) => const HomeView()), -// ]; -// } diff --git a/lib/resource_manager/styles_manager.dart b/lib/resource_manager/styles_manager.dart deleted file mode 100644 index 53961b0..0000000 --- a/lib/resource_manager/styles_manager.dart +++ /dev/null @@ -1,74 +0,0 @@ -// import 'package:flutter/material.dart'; - -// import 'font_manager.dart'; - -// TextStyle _getTextStyle({ -// required double fontSize, -// required Color color, -// required FontWeight fontWeight, -// }) => TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// regular style -// TextStyle getTextStyleRegular({ -// required Color color, double fontSize = FontSize.s14, -// fontWeight = FontsManager.regular, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// light style -// TextStyle getTextStyleLight({ -// required Color color, double fontSize = FontSize.s12, -// fontWeight = FontsManager.light, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// medium style -// TextStyle getTextStyleMedium({ -// required Color color, double fontSize = FontSize.s16, -// fontWeight = FontsManager.medium, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// semi bold style -// TextStyle getTextStyleSemiBold({ -// required Color color, double fontSize = FontSize.s18, -// fontWeight = FontsManager.semiBold, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// bold style -// TextStyle getTextStyleBold({ -// required Color color, double fontSize = FontSize.s20, -// fontWeight = FontsManager.bold, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); - -// /// extra bold style -// TextStyle getTextStyleExtraBold({ -// required Color color, double fontSize = FontSize.s22, -// fontWeight = FontsManager.extraBold, -// }) => _getTextStyle( -// fontSize: fontSize, -// color: color, -// fontWeight: fontWeight, -// ); diff --git a/lib/resource_manager/theme_manager.dart b/lib/resource_manager/theme_manager.dart deleted file mode 100644 index cacbc42..0000000 --- a/lib/resource_manager/theme_manager.dart +++ /dev/null @@ -1,155 +0,0 @@ -// import 'package:flutter/material.dart'; - -// import 'color_manager.dart'; -// import 'font_manager.dart'; -// import 'values_manager.dart'; - -// ThemeData myTheme = ThemeData( -// ///main colors -// primaryColor: ColorsManager.primaryLightColor, -// colorScheme: ColorsManager.lightColorScheme, -// scaffoldBackgroundColor: Colors.white, - -// ///text theme -// textTheme: const TextTheme( -// ///display -// displayLarge: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s35, -// fontWeight: FontsManager.regular, -// color: Colors.black,), -// displayMedium: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s20, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// displaySmall: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s16, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), - -// ///title -// titleLarge: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s48, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// titleMedium: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s30, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// titleSmall: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s25, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), - -// ///body -// bodyLarge: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s18, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// bodyMedium: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s14, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// bodySmall: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s12, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), - -// labelLarge: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s18, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// labelMedium: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s16, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// labelSmall: TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s14, -// fontWeight: FontsManager.regular, -// color: Colors.black, -// ), -// ), - -// ///button theme -// buttonTheme: ButtonThemeData( -// buttonColor: ColorsManager.primaryLightColor, -// padding: const EdgeInsets.symmetric(horizontal: AppPadding.p8), -// textTheme: ButtonTextTheme.primary, -// hoverColor: ColorsManager.primaryDarkColor, -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(AppRadius.r4), -// ),), - -// textButtonTheme: TextButtonThemeData( -// style: ButtonStyle( -// backgroundColor: -// MaterialStateProperty.all(ColorsManager.primaryLightColor), -// padding: MaterialStateProperty.all( -// const EdgeInsets.all(AppPadding.p8),), -// textStyle: MaterialStateProperty.all( -// const TextStyle( -// fontFamily: FontsManager.fontFamily, -// fontSize: FontSize.s16, -// fontWeight: FontsManager.regular, -// color: ColorsManager.onPrimaryLightColor, -// ), -// ), -// // shape: MaterialStateProperty.all( -// // RoundedRectangleBorder( -// // borderRadius: BorderRadius.circular(AppRadius.r4), -// // side: const BorderSide(color: Colors.grey), -// // ), -// // ), -// ), -// ), - -// ///input decoration theme -// inputDecorationTheme: const InputDecorationTheme( -// border: OutlineInputBorder( -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.grey), -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// focusedBorder: OutlineInputBorder( -// borderSide: BorderSide(color: ColorsManager.primaryLightColor), -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// labelStyle: TextStyle( -// fontFamily: FontsManager.fontFamily, -// color: Colors.grey, -// fontSize: FontSize.s16, -// fontWeight: FontsManager.regular, -// ), -// ), - -// ///card theme -// cardTheme: const CardTheme( -// elevation: 0, -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// ), -// ); diff --git a/lib/api/api_links_endpoints.dart b/lib/services/api/api_links_endpoints.dart similarity index 100% rename from lib/api/api_links_endpoints.dart rename to lib/services/api/api_links_endpoints.dart diff --git a/lib/api/http_interceptor.dart b/lib/services/api/http_interceptor.dart similarity index 100% rename from lib/api/http_interceptor.dart rename to lib/services/api/http_interceptor.dart diff --git a/lib/api/http_service.dart b/lib/services/api/http_service.dart similarity index 90% rename from lib/api/http_service.dart rename to lib/services/api/http_service.dart index a3b43ee..7e574f3 100644 --- a/lib/api/http_service.dart +++ b/lib/services/api/http_service.dart @@ -1,10 +1,9 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:syncrow_app/api/http_interceptor.dart'; -import 'package:syncrow_app/helpers/constants.dart'; -import 'package:syncrow_app/helpers/sharedPreferences_helper.dart'; import 'package:syncrow_app/services/locator.dart'; +import 'http_interceptor.dart'; + class HTTPService { final Dio client = locator(); final navigatorKey = GlobalKey(); @@ -44,8 +43,6 @@ class HTTPService { bool showServerMessage = true, }) async { try { - SharedPreferencesHelper.saveBoolToSP( - KeyConstants.showServerMessage, showServerMessage); final response = await client.get( path, queryParameters: queryParameters, @@ -66,8 +63,6 @@ class HTTPService { bool showServerMessage = true, required T Function(dynamic) expectedResponseModel}) async { try { - SharedPreferencesHelper.saveBoolToSP( - KeyConstants.showServerMessage, showServerMessage); final response = await client.post(path, data: body, queryParameters: queryParameters, options: options); debugPrint("status code is ${response.statusCode}"); diff --git a/lib/api/my_http_overrides.dart b/lib/services/api/my_http_overrides.dart similarity index 100% rename from lib/api/my_http_overrides.dart rename to lib/services/api/my_http_overrides.dart diff --git a/lib/api/errors.dart b/lib/services/api/network_exception.dart similarity index 100% rename from lib/api/errors.dart rename to lib/services/api/network_exception.dart diff --git a/lib/services/locator.dart b/lib/services/locator.dart index f6259b1..9ea5fc7 100644 --- a/lib/services/locator.dart +++ b/lib/services/locator.dart @@ -1,6 +1,6 @@ import 'package:get_it/get_it.dart'; -import '../api/http_interceptor.dart'; +import 'api/http_interceptor.dart'; GetIt locator = GetIt.instance; diff --git a/lib/services/navigation_service.dart b/lib/services/navigation_service.dart deleted file mode 100644 index e81d5cc..0000000 --- a/lib/services/navigation_service.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:flutter/material.dart'; - -class NavigationService { - static GlobalKey navigatorKey = GlobalKey(); - static GlobalKey? snackbarKey = GlobalKey(); -} diff --git a/lib/utils/bloc_observer.dart b/lib/utils/bloc_observer.dart new file mode 100644 index 0000000..06ca2b0 --- /dev/null +++ b/lib/utils/bloc_observer.dart @@ -0,0 +1,29 @@ +// ignore_for_file: avoid_print + +import 'package:flutter_bloc/flutter_bloc.dart'; + +class MyBlocObserver extends BlocObserver { + @override + void onCreate(BlocBase bloc) { + super.onCreate(bloc); + print('onCreate -- ${bloc.runtimeType}'); + } + + @override + void onChange(BlocBase bloc, Change change) { + super.onChange(bloc, change); + print('onChange -- ${bloc.runtimeType}, $change'); + } + + @override + void onError(BlocBase bloc, Object error, StackTrace stackTrace) { + print('onError -- ${bloc.runtimeType}, $error'); + super.onError(bloc, error, stackTrace); + } + + @override + void onClose(BlocBase bloc) { + super.onClose(bloc); + print('onClose -- ${bloc.runtimeType}'); + } +} \ No newline at end of file diff --git a/lib/local/cache_helper.dart b/lib/utils/helpers/cache_helper.dart similarity index 100% rename from lib/local/cache_helper.dart rename to lib/utils/helpers/cache_helper.dart diff --git a/lib/helpers/file_helper.dart b/lib/utils/helpers/file_helper.dart similarity index 100% rename from lib/helpers/file_helper.dart rename to lib/utils/helpers/file_helper.dart diff --git a/lib/helpers/life_cycle_event_handler.dart b/lib/utils/helpers/life_cycle_event_handler.dart similarity index 100% rename from lib/helpers/life_cycle_event_handler.dart rename to lib/utils/helpers/life_cycle_event_handler.dart diff --git a/lib/helpers/localization_helpers.dart b/lib/utils/helpers/localization_helpers.dart similarity index 68% rename from lib/helpers/localization_helpers.dart rename to lib/utils/helpers/localization_helpers.dart index 54f1435..95690ab 100644 --- a/lib/helpers/localization_helpers.dart +++ b/lib/utils/helpers/localization_helpers.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'constants.dart'; - class LocalizationService { static saveLocale(Locale locale) async { SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -14,13 +12,13 @@ class LocalizationService { static Future savedLocale() async { SharedPreferences prefs = await SharedPreferences.getInstance(); - var savedLanguageCode = prefs.getString(KeyConstants.languageCode); - var savedCountryCode = prefs.getString(KeyConstants.countryCode); + // var savedLanguageCode = prefs.getString(Constants.languageCode); + // var savedCountryCode = prefs.getString(Constants.countryCode); var savedLocale = const Locale("ar", "JO"); - if (savedCountryCode != null && savedLanguageCode != null) { - savedLocale = Locale(savedLanguageCode, savedCountryCode); - } + // if (savedCountryCode != null && savedLanguageCode != null) { + // savedLocale = Locale(savedLanguageCode, savedCountryCode); + // } return savedLocale; } diff --git a/lib/helpers/misc_string_helpers.dart b/lib/utils/helpers/misc_string_helpers.dart similarity index 100% rename from lib/helpers/misc_string_helpers.dart rename to lib/utils/helpers/misc_string_helpers.dart diff --git a/lib/helpers/parser_helper.dart b/lib/utils/helpers/parser_helper.dart similarity index 98% rename from lib/helpers/parser_helper.dart rename to lib/utils/helpers/parser_helper.dart index 0806d53..0ae3a5e 100644 --- a/lib/helpers/parser_helper.dart +++ b/lib/utils/helpers/parser_helper.dart @@ -1,6 +1,7 @@ import 'package:intl/intl.dart'; class ParserHelper { + //todo : convert to extension static int parseInt(String value) { int result; try { diff --git a/lib/helpers/phone_number_formatter.dart b/lib/utils/helpers/phone_number_formatter.dart similarity index 100% rename from lib/helpers/phone_number_formatter.dart rename to lib/utils/helpers/phone_number_formatter.dart diff --git a/lib/helpers/sharedPreferences_helper.dart b/lib/utils/helpers/sharedPreferences_helper.dart similarity index 100% rename from lib/helpers/sharedPreferences_helper.dart rename to lib/utils/helpers/sharedPreferences_helper.dart diff --git a/lib/helpers/url_launcher.dart b/lib/utils/helpers/url_launcher.dart similarity index 100% rename from lib/helpers/url_launcher.dart rename to lib/utils/helpers/url_launcher.dart diff --git a/lib/resource_manager/assets_manager.dart b/lib/utils/resource_manager/assets_manager.dart similarity index 87% rename from lib/resource_manager/assets_manager.dart rename to lib/utils/resource_manager/assets_manager.dart index 8e1f813..bcf4dc7 100644 --- a/lib/resource_manager/assets_manager.dart +++ b/lib/utils/resource_manager/assets_manager.dart @@ -4,6 +4,7 @@ class ImageManager { static const String whiteLogo = '$base/white-logo.png'; static const String blackLogo = '$base/black-logo.png'; static const String boxEmpty = '$base/box-empty.jpg'; + static const String automation = '$base/automation.jpg'; } class IconsManager { diff --git a/lib/resource_manager/color_manager.dart b/lib/utils/resource_manager/color_manager.dart similarity index 100% rename from lib/resource_manager/color_manager.dart rename to lib/utils/resource_manager/color_manager.dart diff --git a/lib/resource_manager/constants.dart b/lib/utils/resource_manager/constants.dart similarity index 100% rename from lib/resource_manager/constants.dart rename to lib/utils/resource_manager/constants.dart diff --git a/lib/utils/resource_manager/font_manager.dart b/lib/utils/resource_manager/font_manager.dart new file mode 100644 index 0000000..691e3e0 --- /dev/null +++ b/lib/utils/resource_manager/font_manager.dart @@ -0,0 +1,45 @@ +import 'dart:ui'; + +/// # To add custom fonts to your application, add a fonts section here, +/// # in this "flutter" section. Each entry in this list should have a +/// # "family" key with the font family name, and a "fonts" key with a +/// # list giving the asset and other descriptors for the font. For +/// # example: +/// +/// fonts: +/// - family:Montserrat +/// fonts: +/// - asset: assets/ fonts/Montserrat-Botd. ttf +/// weight: 700 +/// - asset: assets/ fonts/Montserrat-SemiB01d. ttf +/// weight: 600 + +class FontsManager { + static const FontWeight light = FontWeight.w300; + static const FontWeight regular = FontWeight.w400; + static const FontWeight medium = FontWeight.w500; + static const FontWeight semiBold = FontWeight.w600; + static const FontWeight bold = FontWeight.w700; + static const FontWeight extraBold = FontWeight.w800; + static const FontWeight black = FontWeight.w900; + + static const String fontFamily = 'Aftika'; +} + +class FontSize { + static const double s12 = 12; + static const double s10 = 10; + static const double s14 = 14; + static const double s16 = 16; + static const double s18 = 18; + static const double s20 = 20; + static const double s21 = 21; + static const double s22 = 22; + static const double s24 = 24; + static const double s25 = 25; + static const double s26 = 26; + static const double s28 = 28; + static const double s30 = 30; + static const double s35 = 35; + static const double s48 = 48; +} diff --git a/lib/resource_manager/strings_manager.dart b/lib/utils/resource_manager/strings_manager.dart similarity index 100% rename from lib/resource_manager/strings_manager.dart rename to lib/utils/resource_manager/strings_manager.dart diff --git a/lib/utils/resource_manager/styles_manager.dart b/lib/utils/resource_manager/styles_manager.dart new file mode 100644 index 0000000..f4c181a --- /dev/null +++ b/lib/utils/resource_manager/styles_manager.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; + +import 'font_manager.dart'; + +TextStyle _getTextStyle({ + required double fontSize, + required Color color, + required FontWeight fontWeight, +}) => + TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// regular style +TextStyle getTextStyleRegular({ + required Color color, + double fontSize = FontSize.s14, + fontWeight = FontsManager.regular, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// light style +TextStyle getTextStyleLight({ + required Color color, + double fontSize = FontSize.s12, + fontWeight = FontsManager.light, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// medium style +TextStyle getTextStyleMedium({ + required Color color, + double fontSize = FontSize.s16, + fontWeight = FontsManager.medium, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// semi bold style +TextStyle getTextStyleSemiBold({ + required Color color, + double fontSize = FontSize.s18, + fontWeight = FontsManager.semiBold, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// bold style +TextStyle getTextStyleBold({ + required Color color, + double fontSize = FontSize.s20, + fontWeight = FontsManager.bold, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); + +/// extra bold style +TextStyle getTextStyleExtraBold({ + required Color color, + double fontSize = FontSize.s22, + fontWeight = FontsManager.extraBold, +}) => + _getTextStyle( + fontSize: fontSize, + color: color, + fontWeight: fontWeight, + ); diff --git a/lib/utils/resource_manager/theme_manager.dart b/lib/utils/resource_manager/theme_manager.dart new file mode 100644 index 0000000..867c04a --- /dev/null +++ b/lib/utils/resource_manager/theme_manager.dart @@ -0,0 +1,156 @@ +import 'package:flutter/material.dart'; + +import 'color_manager.dart'; +import 'font_manager.dart'; + +ThemeData myTheme = ThemeData( + ///main colors + primaryColor: ColorsManager.primaryColor, + // colorScheme: ColorsManager.lightColorScheme, + scaffoldBackgroundColor: Colors.white, + + ///text theme + textTheme: const TextTheme( + ///display + displayLarge: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s35, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + displayMedium: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s20, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + displaySmall: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s16, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + + ///title + titleLarge: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s48, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + titleMedium: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s30, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + titleSmall: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s25, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + + ///body + bodyLarge: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s18, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + bodyMedium: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s14, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + bodySmall: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s12, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + + labelLarge: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s18, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + labelMedium: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s16, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + labelSmall: TextStyle( + fontFamily: FontsManager.fontFamily, + fontSize: FontSize.s14, + fontWeight: FontsManager.regular, + color: Colors.black, + ), + ), + + ///button theme + // buttonTheme: ButtonThemeData( + // buttonColor: ColorsManager.primaryLightColor, + // padding: const EdgeInsets.symmetric(horizontal: AppPadding.p8), + // textTheme: ButtonTextTheme.primary, + // hoverColor: ColorsManager.primaryDarkColor, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(AppRadius.r4), + // ),), + // + // textButtonTheme: TextButtonThemeData( + // style: ButtonStyle( + // backgroundColor: + // MaterialStateProperty.all(ColorsManager.primaryLightColor), + // padding: MaterialStateProperty.all( + // const EdgeInsets.all(AppPadding.p8),), + // textStyle: MaterialStateProperty.all( + // const TextStyle( + // fontFamily: FontsManager.fontFamily, + // fontSize: FontSize.s16, + // fontWeight: FontsManager.regular, + // color: ColorsManager.onPrimaryLightColor, + // ), + // ), + // // shape: MaterialStateProperty.all( + // // RoundedRectangleBorder( + // // borderRadius: BorderRadius.circular(AppRadius.r4), + // // side: const BorderSide(color: Colors.grey), + // // ), + // // ), + // ), + // ), + + ///input decoration theme + inputDecorationTheme: const InputDecorationTheme( + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey), + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: ColorsManager.primaryColor), + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + labelStyle: TextStyle( + fontFamily: FontsManager.fontFamily, + color: Colors.grey, + fontSize: FontSize.s16, + fontWeight: FontsManager.regular, + ), + ), + + ///card theme + //TODO edit card theme + cardTheme: const CardTheme( + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + ), +); diff --git a/lib/resource_manager/values_manager.dart b/lib/utils/resource_manager/values_manager.dart similarity index 100% rename from lib/resource_manager/values_manager.dart rename to lib/utils/resource_manager/values_manager.dart diff --git a/lib/utils/responsive/responsive.dart b/lib/utils/responsive/responsive.dart deleted file mode 100644 index 742777a..0000000 --- a/lib/utils/responsive/responsive.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:flutter/material.dart'; - -class Responsive extends StatelessWidget { - final Widget mobile; - final Widget? tablet; - final Widget desktop; - - const Responsive({ - super.key, - required this.mobile, - this.tablet, - required this.desktop, - }); - -// This size work fine on my design, maybe you need some customization depends on your design - - // This isMobile, isTablet, isDesktop help us later - static bool isMobile(BuildContext context) => - MediaQuery.of(context).size.width < 850; - - static bool isTablet(BuildContext context) => - MediaQuery.of(context).size.width < 1100 && - MediaQuery.of(context).size.width >= 850; - - static bool isDesktop(BuildContext context) => - MediaQuery.of(context).size.width >= 1100; - - @override - Widget build(BuildContext context) { - final Size size = MediaQuery.of(context).size; - // If our width is more than 1100 then we consider it a desktop - if (size.width >= 1100) { - return desktop; - } - // If width it less then 1100 and more then 850 we consider it as tablet - else if (size.width >= 850 && tablet != null) { - return tablet!; - } - // Or less then that we called it mobile - else { - return mobile; - } - } -} diff --git a/pubspec.lock b/pubspec.lock index bb1677a..13815b6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + bloc: + dependency: transitive + description: + name: bloc + sha256: f53a110e3b48dcd78136c10daa5d51512443cea5e1348c9d80a320095fa2db9e + url: "https://pub.dev" + source: hosted + version: "8.1.3" boolean_selector: dependency: transitive description: @@ -206,6 +214,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: "87325da1ac757fcc4813e6b34ed5dd61169973871fdf181d6c2109dd6935ece1" + url: "https://pub.dev" + source: hosted + version: "8.1.4" flutter_cache_manager: dependency: transitive description: @@ -470,7 +486,7 @@ packages: source: hosted version: "2.1.8" provider: - dependency: "direct main" + dependency: transitive description: name: provider sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" diff --git a/pubspec.yaml b/pubspec.yaml index 5d69049..20b5b39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: url_launcher: ^6.2.4 dio: ^5.4.0 flutter_localization: ^0.2.0 - provider: ^6.1.1 + flutter_bloc: ^8.1.4 firebase_core: ^2.25.4 firebase_analytics: ^10.8.5 firebase_crashlytics: ^3.4.14 @@ -45,12 +45,10 @@ flutter: - assets/images/ - assets/icons/ - assets/fonts/ - #fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic + fonts: + - family: Aftika + fonts: + - asset: assets/fonts/AftikaRegular.ttf # # - family: Trajan Pro # fonts: