From c0ad2d6b91cac2c9b63f4e10ffa8a1b7acb5a23e Mon Sep 17 00:00:00 2001 From: rajshinde046 Date: Thu, 2 May 2024 16:56:33 +0530 Subject: [PATCH 1/2] bloc --- .vscode/settings.json | 3 +- lib/data/network/network_api_services.dart | 2 +- lib/main.dart | 15 +- lib/resources/routes/routes.dart | 2 +- lib/view/login/LoginScreen.dart | 695 +++++++++++--------- lib/view/login/VerifyOtp.dart | 2 +- lib/view_model/LoginPage/Loginbloc.dart | 24 + lib/view_model/LoginPage/Loginobserver.dart | 14 + lib/view_model/SendOtp/sendOtpObserver.dart | 24 + lib/view_model/SendOtp/sendOtpbloc.dart | 33 + pubspec.lock | 24 + pubspec.yaml | 2 + 12 files changed, 513 insertions(+), 327 deletions(-) create mode 100644 lib/view_model/LoginPage/Loginbloc.dart create mode 100644 lib/view_model/LoginPage/Loginobserver.dart create mode 100644 lib/view_model/SendOtp/sendOtpObserver.dart create mode 100644 lib/view_model/SendOtp/sendOtpbloc.dart diff --git a/.vscode/settings.json b/.vscode/settings.json index c5f3f6b..2a96dec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "java.configuration.updateBuildConfiguration": "interactive" + "java.configuration.updateBuildConfiguration": "interactive", + "dart.flutterSdkPath": "D:\\pooja\\fluttersdk\\flutter_3.16.9\\flutter" } \ No newline at end of file diff --git a/lib/data/network/network_api_services.dart b/lib/data/network/network_api_services.dart index 297b210..a669ce5 100644 --- a/lib/data/network/network_api_services.dart +++ b/lib/data/network/network_api_services.dart @@ -7,7 +7,7 @@ import 'package:traderscircuit/Utils/utils.dart'; import '../../Utils/base_manager.dart'; import 'base_api_services.dart'; -class NetworkApiServices extends BaseApiServices { +class NetworkApiServices { Dio dio = Dio(); String basicAuth = 'Basic ' + base64.encode( diff --git a/lib/main.dart b/lib/main.dart index 9624b71..fd04b83 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -13,6 +14,9 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:traderscircuit/resources/routes/routes.dart'; import 'package:onesignal_flutter/onesignal_flutter.dart'; +import 'view_model/LoginPage/Loginbloc.dart'; +import 'view_model/SendOtp/sendOtpbloc.dart'; + Future main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -39,7 +43,16 @@ Future main() async { ); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, - ]).then((value) => runApp(const MyApp())); + ]).then((value) => runApp(MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => CounterBloc(), + ), + BlocProvider( + create: (context) => SendOtpBloc(), + ), + // Add more BlocProviders for other Blocs here if needed + ],child: const MyApp()))); } class MyApp extends StatefulWidget { diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 485fc74..283d539 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -86,7 +86,7 @@ class AppRoutes { ), GetPage( name: RouteName.verifyotp, - page: () => const VerifyOTP(), + page: () => VerifyOTP(), ), //secureaccess diff --git a/lib/view/login/LoginScreen.dart b/lib/view/login/LoginScreen.dart index e0cfb95..c61bad2 100644 --- a/lib/view/login/LoginScreen.dart +++ b/lib/view/login/LoginScreen.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; @@ -11,9 +12,15 @@ import 'package:traderscircuit/Utils/base_manager.dart'; import 'package:traderscircuit/Utils/text.dart'; import 'package:traderscircuit/Utils/utils.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; +import 'package:traderscircuit/view/login/VerifyOtp.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; import 'package:traderscircuit/view_model/Login/send_otp_api.dart'; import 'package:traderscircuit/Utils/Dialogs.dart'; +import 'package:traderscircuit/view_model/LoginPage/Loginbloc.dart'; + +import '../../view_model/LoginPage/Loginobserver.dart'; +import '../../view_model/SendOtp/sendOtpObserver.dart'; +import '../../view_model/SendOtp/sendOtpbloc.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @@ -33,6 +40,9 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { + // final CounterBloc counterbloc = BlocProvider.of(context); + //final sendOtpBloc = context.read(); + return WillPopScope( onWillPop: () async { _onBackButtonPressed(context); @@ -41,343 +51,383 @@ class _LoginScreenState extends State { child: Scaffold( backgroundColor: Colors.black, extendBody: true, - body: Stack( - children: [ - const CommonBlurLeft(), - const CommonBlurRight(), - Stack( - children: [ - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: Form( - key: _sendotpform, - child: ListView( - physics: const BouncingScrollPhysics(), - // mainAxisAlignment: MainAxisAlignment.start, - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20.h, - ), - const Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Traders Circuit", - style: TextStyle( - fontFamily: 'hiragino', - color: Colors.white, - fontSize: 25, - fontWeight: FontWeight.w600), - ), - ], - ), - SizedBox( - height: 42.h, - ), - const Text( - "Lets get started ", - style: TextStyle( - fontFamily: 'hiragino', - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 10.h, - ), - text18W800("Enter your mobile number to get otp"), - SizedBox( - height: 35.h, - ), - Row( - children: [ - Expanded( - child: GlassmorphicContainer( - width: 60, - height: 50, - borderRadius: 8, - blur: 10, - alignment: Alignment.center, - border: 0.8, - linearGradient: LinearGradient( + body: BlocProvider( + create: (context) => SendOtpBloc(), + child: Stack( + children: [ + const CommonBlurLeft(), + const CommonBlurRight(), + Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 16), + child: Form( + key: _sendotpform, + child: ListView( + physics: const BouncingScrollPhysics(), + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 20.h, + ), + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Traders Circuit", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 25, + fontWeight: FontWeight.w600), + ), + ], + ), + SizedBox( + height: 42.h, + ), + //bloc implementation + /* GestureDetector( + onTap: () { + counterbloc.add(NumberIncreaseEvent()); + }, + child: SizedBox( + height: 80.h, + child: Text( + "click me", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + ), + ), + if (state is UpdateState) + Text( + "${state.counter}", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + */ + const Text( + "Lets get started ", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + SizedBox( + height: 10.h, + ), + text18W800("Enter your mobile number to get otp"), + SizedBox( + height: 35.h, + ), + Row( + children: [ + Expanded( + child: GlassmorphicContainer( + width: 60, + height: 50, + borderRadius: 8, + blur: 10, + alignment: Alignment.center, + border: 0.8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Colors.white.withOpacity(0.1), + const Color(0xFFFFFFFF) + .withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - Colors.white.withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // SvgPicture.asset("assets/images/svg/india.svg"), - Image.asset( - "assets/images/png/india.png", - height: 25.h, - width: 25.h, - ), - const SizedBox( - width: 2, - ), - const Text( - "+91", - style: TextStyle( - fontFamily: 'hiragino', - fontSize: 15, - color: Colors.white, + ), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // SvgPicture.asset("assets/images/svg/india.svg"), + Image.asset( + "assets/images/png/india.png", + height: 25.h, + width: 25.h, ), - ) - ], + const SizedBox( + width: 2, + ), + const Text( + "+91", + style: TextStyle( + fontFamily: 'hiragino', + fontSize: 15, + color: Colors.white, + ), + ) + ], + ), ), ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: 285.w, - child: CustomTextFormField( - texttype: TextInputType.phone, - textEditingController: phonecontroller, - // validator: (value) { - // if (value.isEmpty) { - // return 'Enter your phone number'; - // } else if (!RegExp(r'(^(?:[+0]9)?[0-9]{10}$)') - // .hasMatch(value)) { - // return 'Enter a valid phone number'; - // } else if (!isValidPhoneNumber(value)) { - // return 'Phone number cannot contain 10 zeros'; - // } - // return null; - // }, - inputFormatters: [ - LengthLimitingTextInputFormatter(10), - FilteringTextInputFormatter.allow( - RegExp('[0-9]')), + const SizedBox( + width: 10, + ), + SizedBox( + width: 285.w, + child: CustomTextFormField( + texttype: TextInputType.phone, + textEditingController: phonecontroller, + // validator: (value) { + // if (value.isEmpty) { + // return 'Enter your phone number'; + // } else if (!RegExp(r'(^(?:[+0]9)?[0-9]{10}$)') + // .hasMatch(value)) { + // return 'Enter a valid phone number'; + // } else if (!isValidPhoneNumber(value)) { + // return 'Phone number cannot contain 10 zeros'; + // } + // return null; + // }, + inputFormatters: [ + LengthLimitingTextInputFormatter(10), + FilteringTextInputFormatter.allow( + RegExp('[0-9]')), + ], + ), + ) + ], + ), + const SizedBox( + height: 10, + ), + text14W300( + "We’ll send six digit code to the registered number. Standard data rates may apply"), + SizedBox( + height: 65.h, + ), + + BlocConsumer( + listener: (context, state) { + if (state == SendOtpState.success) { + WidgetsBinding.instance + ?.addPostFrameCallback((_) { + Get.toNamed(RouteName.verifyotp, arguments: { + "phonenumber": phonecontroller.text, + }); + }); + } else if (state == SendOtpState.failure) { + Utils.showToast("Oops something went wrong"); + } + }, builder: (context, state) { + print(state); + if (state == SendOtpState.loading) { + return Center( + child: Container( + height: 40, + width: 40, + child: CircularProgressIndicator())); + } + return CommonBtn( + text: "Login/Signup", + onTap: () async { + final isValid = + _sendotpform.currentState?.validate(); + if (isValid!) { + FocusManager.instance.primaryFocus + ?.unfocus(); + if (isValid != null && isValid) { + Map myLoginData = { + "mobile_number": phonecontroller.text, + }; + context + .read() + .add(SendOtp(myLoginData)); + } else { + ScaffoldMessenger.of(context) + .showSnackBar( + SnackBar( + content: Text( + 'Please enter valid phone number'), + ), + ); + } + } + }); + }), + + SizedBox( + height: 10.h, + ), + text14W300( + "By continuing, you agree to our Terms & Conditions"), + SizedBox( + height: 45.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + height: 0.2.h, + width: 108.w, + color: Colors.white, + ), + SizedBox( + width: 22.w, + ), + text18W600("OR"), + SizedBox( + width: 22.w, + ), + Container( + height: 0.2.h, + width: 108.w, + color: Colors.white, + ), + ], + ), + SizedBox( + height: 40.h, + ), + GlassmorphicContainer( + width: double.infinity, + height: 55.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.3, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFAF2E89).withOpacity(0.2), + const Color(0xFFA23E31).withOpacity(0.2), + const Color(0xFF0000).withOpacity(0.2), + ], + stops: const [ + 0.3, + 0.6, + 1, + ]), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + "assets/images/png/apple.png", + height: 30.h, + width: 30.w, + ), + SizedBox( + width: 7.h, + ), + text16W400("Continue with apple"), ], ), - ) - ], - ), - const SizedBox( - height: 10, - ), - text14W300( - "We’ll send six digit code to the registered number. Standard data rates may apply"), - SizedBox( - height: 65.h, - ), - CommonBtn( - text: "Login/Signup", - onTap: () async { - final isValid = - _sendotpform.currentState?.validate(); - if (isValid!) { - utils.loader(); - FocusManager.instance.primaryFocus?.unfocus(); - - Map myLoginData = { - "mobile_number": phonecontroller.text, - }; - - var resp = - await SendOtpAPI(myLoginData).sendOtpApi(); - print(resp.status); - print('Api msg : ${resp.message}'); - - if (resp.status == ResponseStatus.SUCCESS) { - Get.back(); - print("api response is ${resp.data}"); - Utils.showToast("OTP sent successfully"); - - Map res = resp.data; - print(res); - - Get.toNamed(RouteName.verifyotp, arguments: { - "phonenumber": phonecontroller.text - }); - } else { - Get.back(); - Utils.showToast(resp.message); - print('Api msg : ${resp.message}'); - } - } else { - Get.snackbar( - "Error", "Please Enter Login Credentials", - margin: EdgeInsets.all(8), - snackStyle: SnackStyle.FLOATING, - snackPosition: SnackPosition.BOTTOM); - } - }), - SizedBox( - height: 10.h, - ), - text14W300( - "By continuing, you agree to our Terms & Conditions"), - SizedBox( - height: 45.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: 0.2.h, - width: 108.w, - color: Colors.white, - ), - SizedBox( - width: 22.w, - ), - text18W600("OR"), - SizedBox( - width: 22.w, - ), - Container( - height: 0.2.h, - width: 108.w, - color: Colors.white, - ), - ], - ), - SizedBox( - height: 40.h, - ), - GlassmorphicContainer( - width: double.infinity, - height: 55.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: const [ - 0.1, - 1, - ]), - border: 0.3, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFAF2E89).withOpacity(0.2), - const Color(0xFFA23E31).withOpacity(0.2), - const Color(0xFF0000).withOpacity(0.2), - ], - stops: const [ - 0.3, - 0.6, - 1, - ]), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - "assets/images/png/apple.png", - height: 30.h, - width: 30.w, - ), - SizedBox( - width: 7.h, - ), - text16W400("Continue with apple"), - ], ), ), - ), - SizedBox( - height: 15.h, - ), - GlassmorphicContainer( - width: double.infinity, - height: 55.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: const [ - 0.1, - 1, - ]), - border: 0.5, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFAF2E89).withOpacity(0.2), - const Color(0xFFA23E31).withOpacity(0.2), - const Color(0xFF0000).withOpacity(0.2), - ], - stops: const [ - 0.3, - 0.6, - 1, - ]), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - "assets/images/png/google.png", - height: 30.h, - width: 30.w, - ), - SizedBox( - width: 7.h, - ), - text16W400( - "Continue with google", - ), - ], - ), + SizedBox( + height: 15.h, ), - ), - SizedBox( - height: 45.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( - onTap: () { - Get.toNamed(RouteName.mainscreen); - }, - child: text16W700( - "Continue as guest", + GlassmorphicContainer( + width: double.infinity, + height: 55.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.5, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFAF2E89).withOpacity(0.2), + const Color(0xFFA23E31).withOpacity(0.2), + const Color(0xFF0000).withOpacity(0.2), + ], + stops: const [ + 0.3, + 0.6, + 1, + ]), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + "assets/images/png/google.png", + height: 30.h, + width: 30.w, + ), + SizedBox( + width: 7.h, + ), + text16W400( + "Continue with google", + ), + ], ), ), - ], - ) - ], + ), + SizedBox( + height: 45.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + Get.toNamed(RouteName.mainscreen); + }, + child: text16W700( + "Continue as guest", + ), + ), + ], + ) + ], + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); @@ -419,4 +469,5 @@ class _LoginScreenState extends State { ); }); return exitApp ?? false; - }} + } +} diff --git a/lib/view/login/VerifyOtp.dart b/lib/view/login/VerifyOtp.dart index 6582545..88b1dcd 100644 --- a/lib/view/login/VerifyOtp.dart +++ b/lib/view/login/VerifyOtp.dart @@ -20,7 +20,7 @@ int? isKycUpdated; int? isSecuredAccess; class VerifyOTP extends StatefulWidget { - const VerifyOTP({super.key}); + VerifyOTP({super.key}); @override State createState() => _VerifyOTPState(); diff --git a/lib/view_model/LoginPage/Loginbloc.dart b/lib/view_model/LoginPage/Loginbloc.dart new file mode 100644 index 0000000..19cb21d --- /dev/null +++ b/lib/view_model/LoginPage/Loginbloc.dart @@ -0,0 +1,24 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'Loginobserver.dart'; + +class CounterBloc extends Bloc { + int counter = 0; + + CounterBloc() : super(UpdateState(0)) { + on(onNumberIncrease); + on(onNumberDecrease); + } + + void onNumberIncrease( + NumberIncreaseEvent event, Emitter emit) async { + counter = counter + 1; + emit(UpdateState(counter)); + } + + void onNumberDecrease( + NumberDecreaseEvent event, Emitter emit) async { + counter = counter - 1; + emit(UpdateState(counter)); + } +} \ No newline at end of file diff --git a/lib/view_model/LoginPage/Loginobserver.dart b/lib/view_model/LoginPage/Loginobserver.dart new file mode 100644 index 0000000..1bcea4a --- /dev/null +++ b/lib/view_model/LoginPage/Loginobserver.dart @@ -0,0 +1,14 @@ +class CounterEvents {} + +class NumberIncreaseEvent extends CounterEvents {} + +class NumberDecreaseEvent extends CounterEvents {} + +class CounterStates {} + +class InitialState extends CounterStates {} + +class UpdateState extends CounterStates { + final int counter; + UpdateState(this.counter); +} \ No newline at end of file diff --git a/lib/view_model/SendOtp/sendOtpObserver.dart b/lib/view_model/SendOtp/sendOtpObserver.dart new file mode 100644 index 0000000..a0b7bc7 --- /dev/null +++ b/lib/view_model/SendOtp/sendOtpObserver.dart @@ -0,0 +1,24 @@ +import 'package:equatable/equatable.dart'; + +// Define events +abstract class SendOtpEvent { + const SendOtpEvent(); + + @override + List get props => []; +} + +class SendOtp extends SendOtpEvent { + final Map loginData; + SendOtp(this.loginData){ + + } + + @override + List get props => [loginData]; + +} + +// Define states +enum SendOtpState { initial, loading, success, failure } + diff --git a/lib/view_model/SendOtp/sendOtpbloc.dart b/lib/view_model/SendOtp/sendOtpbloc.dart new file mode 100644 index 0000000..0ba9db0 --- /dev/null +++ b/lib/view_model/SendOtp/sendOtpbloc.dart @@ -0,0 +1,33 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:get/get.dart'; + +import '../../Utils/base_manager.dart'; +import '../../resources/routes/route_name.dart'; +import '../Login/send_otp_api.dart'; +import 'sendOtpObserver.dart'; + +class SendOtpBloc extends Bloc { + SendOtpBloc() : super(SendOtpState.initial) { + on(mapEventToState); + } + Future mapEventToState( + SendOtp event, Emitter emit) async { + if (event is SendOtp) { + emit(SendOtpState.loading); + try { + final loginData = event.loginData; + var resp = await SendOtpAPI(loginData).sendOtpApi(); + + if (resp.status == ResponseStatus.SUCCESS) { + emit(SendOtpState.success); + } else { + emit(SendOtpState.failure); + } + } catch (e) { + emit(SendOtpState.failure); + } + } + } +} + + diff --git a/pubspec.lock b/pubspec.lock index 0a94cf1..cfbb997 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + bloc: + dependency: transitive + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" boolean_selector: dependency: transitive description: @@ -217,6 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.9" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" expansion_tile_group: dependency: "direct main" description: @@ -318,6 +334,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: f0ecf6e6eb955193ca60af2d5ca39565a86b8a142452c5b24d96fb477428f4d2 + url: "https://pub.dev" + source: hosted + version: "8.1.5" flutter_branch_sdk: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cdbbd7d..bbf3bac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,8 @@ dependencies: audio_video_progress_bar: ^2.0.2 syncfusion_flutter_pdfviewer: flutter_html: ^3.0.0-beta.2 + flutter_bloc: ^8.1.5 + equatable: ^2.0.5 dev_dependencies: flutter_test: From ead927fb0f3d96d45af750be1c023ed036614f75 Mon Sep 17 00:00:00 2001 From: jayesh Date: Thu, 2 May 2024 18:41:33 +0530 Subject: [PATCH 2/2] product recommendations api integration - pending --- lib/Utils/Common/CommonAppBar.dart | 1 - lib/Utils/api_urls.dart | 9 + lib/controller/products_controller.dart | 9 + lib/main.dart | 2 + .../call_recommendations_model.dart | 199 +++++++++ .../ProductsModel/list_of_products_model.dart | 140 ++++++ lib/view/MainScreen/HomeScreen.dart | 82 ++-- lib/view/MainScreen/ShortTrade.dart | 419 +++++++++--------- lib/view/Sidemenu/Sidemenu.dart | 5 +- .../contactUs/contact_us_details.dart | 27 +- .../Sidemenu/contactUs/contact_us_main.dart | 213 +++++++++ lib/view/login/VerifyOtp.dart | 19 +- lib/view/onBoarding/splashScreen.dart | 6 +- lib/view_model/ProductsApi/products_api.dart | 75 ++++ 14 files changed, 943 insertions(+), 263 deletions(-) create mode 100644 lib/controller/products_controller.dart create mode 100644 lib/model/ProductsModel/call_recommendations_model.dart create mode 100644 lib/model/ProductsModel/list_of_products_model.dart create mode 100644 lib/view_model/ProductsApi/products_api.dart diff --git a/lib/Utils/Common/CommonAppBar.dart b/lib/Utils/Common/CommonAppBar.dart index e10faa0..4df8fbd 100644 --- a/lib/Utils/Common/CommonAppBar.dart +++ b/lib/Utils/Common/CommonAppBar.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:traderscircuit/Utils/text.dart'; class CommonAppbar extends StatelessWidget implements PreferredSizeWidget { @override diff --git a/lib/Utils/api_urls.dart b/lib/Utils/api_urls.dart index d7ad28e..c4f6719 100644 --- a/lib/Utils/api_urls.dart +++ b/lib/Utils/api_urls.dart @@ -62,4 +62,13 @@ class ApiUrls { "${base}get-detailed-ticket-data-with-chats/"; static String sendMessage = "${base}send-message-to-admin"; static String updateTicketStatusApi = "${base}update-ticket-status"; + + //Products + static String getListOfProducts = "${base}list-of-products"; + static String getOptionsRecommendations = + "${base}get-options-recommendations"; + static String getSwingTradeRecommendations = + "${base}get-swing-trade-recommendations"; + static String getMultibaggerRecommendations = + "${base}get-multibagger-recommendations"; } diff --git a/lib/controller/products_controller.dart b/lib/controller/products_controller.dart new file mode 100644 index 0000000..3abe3e8 --- /dev/null +++ b/lib/controller/products_controller.dart @@ -0,0 +1,9 @@ +import 'package:get/get.dart'; +import 'package:traderscircuit/model/ProductsModel/call_recommendations_model.dart'; + +class ProductsController extends GetxController { + RxBool isLoaded = true.obs; + CallRecommendationsModel swingTradeModel = CallRecommendationsModel(); + CallRecommendationsModel multibaggerModel = CallRecommendationsModel(); + CallRecommendationsModel optionModel = CallRecommendationsModel(); +} diff --git a/lib/main.dart b/lib/main.dart index 9624b71..f110e5e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:developer'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; @@ -24,6 +25,7 @@ Future main() async { OneSignal.shared.promptUserForPushNotificationPermission(); OneSignal.shared .setSubscriptionObserver((OSSubscriptionStateChanges changes) async { + log(changes.to.userId!.toString()); await prefs.setString('playerId', changes.to.userId!); }); // GlobalVariables globalVariables = GlobalVariables(); diff --git a/lib/model/ProductsModel/call_recommendations_model.dart b/lib/model/ProductsModel/call_recommendations_model.dart new file mode 100644 index 0000000..47c1dd0 --- /dev/null +++ b/lib/model/ProductsModel/call_recommendations_model.dart @@ -0,0 +1,199 @@ +class CallRecommendationsModel { + String? status; + int? statusCode; + String? message; + Data? data; + + CallRecommendationsModel( + {this.status, this.statusCode, this.message, this.data}); + + CallRecommendationsModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['status'] = status; + data['status_code'] = statusCode; + data['message'] = message; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? activeCalls; + List? exitedCalls; + + Data({this.activeCalls, this.exitedCalls}); + + Data.fromJson(Map json) { + if (json['active_calls'] != null) { + activeCalls = []; + json['active_calls'].forEach((v) { + activeCalls!.add(ActiveCalls.fromJson(v)); + }); + } + if (json['exited_calls'] != null) { + exitedCalls = []; + json['exited_calls'].forEach((v) { + exitedCalls!.add(ActiveCalls.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (activeCalls != null) { + data['active_calls'] = activeCalls!.map((v) => v.toJson()).toList(); + } + if (exitedCalls != null) { + data['exited_calls'] = exitedCalls!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ActiveCalls { + int? id; + int? manageProductXid; + int? recommendationActionsXid; + String? stockName; + String? instrumentKey; + String? stockImage; + String? qty; + String? duration; + int? currentPrice; + int? buyPrice; + int? targetPrice; + int? stopLoss; + int? isSendRecommendationNow; + Null? scheduleDateTime; + String? createdAt; + ProductData? productData; + ActionData? actionData; + + ActiveCalls( + {this.id, + this.manageProductXid, + this.recommendationActionsXid, + this.stockName, + this.instrumentKey, + this.stockImage, + this.qty, + this.duration, + this.currentPrice, + this.buyPrice, + this.targetPrice, + this.stopLoss, + this.isSendRecommendationNow, + this.scheduleDateTime, + this.createdAt, + this.productData, + this.actionData}); + + ActiveCalls.fromJson(Map json) { + id = json['id']; + manageProductXid = json['manage_product_xid']; + recommendationActionsXid = json['recommendation_actions_xid']; + stockName = json['stock_name']; + instrumentKey = json['instrument_key']; + stockImage = json['stock_image']; + qty = json['qty']; + duration = json['duration']; + currentPrice = json['current_price']; + buyPrice = json['buy_price']; + targetPrice = json['target_price']; + stopLoss = json['stop_loss']; + isSendRecommendationNow = json['is_send_recommendation_now']; + scheduleDateTime = json['schedule_date_time']; + createdAt = json['created_at']; + productData = json['product_data'] != null + ? ProductData.fromJson(json['product_data']) + : null; + actionData = json['action_data'] != null + ? ActionData.fromJson(json['action_data']) + : null; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['manage_product_xid'] = manageProductXid; + data['recommendation_actions_xid'] = recommendationActionsXid; + data['stock_name'] = stockName; + data['instrument_key'] = instrumentKey; + data['stock_image'] = stockImage; + data['qty'] = qty; + data['duration'] = duration; + data['current_price'] = currentPrice; + data['buy_price'] = buyPrice; + data['target_price'] = targetPrice; + data['stop_loss'] = stopLoss; + data['is_send_recommendation_now'] = isSendRecommendationNow; + data['schedule_date_time'] = scheduleDateTime; + data['created_at'] = createdAt; + if (productData != null) { + data['product_data'] = productData!.toJson(); + } + if (actionData != null) { + data['action_data'] = actionData!.toJson(); + } + return data; + } +} + +class ProductData { + int? id; + String? productName; + int? isActive; + String? createdAt; + + ProductData({this.id, this.productName, this.isActive, this.createdAt}); + + ProductData.fromJson(Map json) { + id = json['id']; + productName = json['product_name']; + isActive = json['is_active']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['product_name'] = productName; + data['is_active'] = isActive; + data['created_at'] = createdAt; + return data; + } +} + +class ActionData { + int? id; + String? name; + int? isActive; + Null? createdAt; + + ActionData({this.id, this.name, this.isActive, this.createdAt}); + + ActionData.fromJson(Map json) { + id = json['id']; + name = json['name']; + isActive = json['is_active']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['name'] = name; + data['is_active'] = isActive; + data['created_at'] = createdAt; + return data; + } +} diff --git a/lib/model/ProductsModel/list_of_products_model.dart b/lib/model/ProductsModel/list_of_products_model.dart new file mode 100644 index 0000000..bf69b9c --- /dev/null +++ b/lib/model/ProductsModel/list_of_products_model.dart @@ -0,0 +1,140 @@ +class ListOfProductsModel { + String? status; + int? statusCode; + String? message; + List? data; + + ListOfProductsModel({this.status, this.statusCode, this.message, this.data}); + + ListOfProductsModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(Data.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['status'] = status; + data['status_code'] = statusCode; + data['message'] = message; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Data { + int? id; + String? title; + List? productsData; + + Data({this.id, this.title, this.productsData}); + + Data.fromJson(Map json) { + id = json['id']; + title = json['title']; + if (json['products_data'] != null) { + productsData = []; + json['products_data'].forEach((v) { + productsData!.add(ProductsData.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['title'] = title; + + if (productsData != null) { + data['products_data'] = productsData!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ProductsData { + int? id; + int? productTypeXid; + int? productTierXid; + String? productName; + String? productDescription; + String? productPrice; + String? productImage; + int? isActive; + String? createdAt; + ProductTier? productTier; + + ProductsData( + {this.id, + this.productTypeXid, + this.productTierXid, + this.productName, + this.productDescription, + this.productPrice, + this.productImage, + this.isActive, + this.createdAt, + this.productTier}); + + ProductsData.fromJson(Map json) { + id = json['id']; + productTypeXid = json['product_type_xid']; + productTierXid = json['product_tier_xid']; + productName = json['product_name']; + productDescription = json['product_description']; + productPrice = json['product_price']; + productImage = json['product_image']; + isActive = json['is_active']; + createdAt = json['created_at']; + productTier = json['product_tier'] != null + ? ProductTier.fromJson(json['product_tier']) + : null; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['product_type_xid'] = productTypeXid; + data['product_tier_xid'] = productTierXid; + data['product_name'] = productName; + data['product_description'] = productDescription; + data['product_price'] = productPrice; + data['product_image'] = productImage; + data['is_active'] = isActive; + data['created_at'] = createdAt; + if (productTier != null) { + data['product_tier'] = productTier!.toJson(); + } + return data; + } +} + +class ProductTier { + int? id; + String? name; + String? createdAt; + + ProductTier({this.id, this.name, this.createdAt}); + + ProductTier.fromJson(Map json) { + id = json['id']; + name = json['name']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['name'] = name; + data['created_at'] = createdAt; + return data; + } +} diff --git a/lib/view/MainScreen/HomeScreen.dart b/lib/view/MainScreen/HomeScreen.dart index af7d213..59ded30 100644 --- a/lib/view/MainScreen/HomeScreen.dart +++ b/lib/view/MainScreen/HomeScreen.dart @@ -7,7 +7,6 @@ import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart'; import 'package:traderscircuit/Utils/Common/CommonTabBar.dart'; -import 'package:traderscircuit/Utils/Common/MainController.dart'; import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart'; import 'package:traderscircuit/Utils/Common/sized_box.dart'; import 'package:traderscircuit/Utils/text.dart'; @@ -17,6 +16,8 @@ import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart'; import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import '../../view_model/ProfileAPI/GetProfileApi.dart'; + class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @@ -26,6 +27,16 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { GlobalKey _scaffoldKey1 = GlobalKey(); + RxString userName = "User".obs; + + @override + void initState() { + GetProfile().GetProfileAPI().then((value) { + userName.value = ProfileObj!.data!.userName ?? "User"; + }); + super.initState(); + } + @override Widget build(BuildContext context) { return WillPopScope( @@ -37,7 +48,7 @@ class _HomeScreenState extends State { drawerEnableOpenDragGesture: false, key: _scaffoldKey1, backgroundColor: Colors.black, - drawer: Container(child: SideMenu()), + drawer: Container(child: const SideMenu()), extendBody: true, appBar: AppBar( scrolledUnderElevation: 0.0, @@ -70,22 +81,25 @@ class _HomeScreenState extends State { ), body: Stack( children: [ - CommonBlurLeft(), - CommonBlurRight(), + const CommonBlurLeft(), + const CommonBlurRight(), Stack(children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 16), child: ListView( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), children: [ sizedBoxHeight(20.h), - Text( - "Welcome Afrid", - style: TextStyle( - color: Colors.white, - fontSize: 24.sp, - fontFamily: 'hiragino', - fontWeight: FontWeight.w500), + Obx( + () => Text( + "Welcome $userName", + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + fontFamily: 'hiragino', + fontWeight: FontWeight.w500), + ), ), sizedBoxHeight(25.h), SingleChildScrollView( @@ -110,7 +124,7 @@ class _HomeScreenState extends State { Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), sizedBoxHeight(30.h), text22W500('View our products'), @@ -147,7 +161,7 @@ class _HomeScreenState extends State { Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), sizedBoxHeight(25.h), Row( @@ -163,10 +177,10 @@ class _HomeScreenState extends State { height: 35.h, width: 105.w, decoration: BoxDecoration( - color: Color(0xFF3A3A3A).withOpacity(0.6), + color: const Color(0xFF3A3A3A).withOpacity(0.6), borderRadius: BorderRadius.circular(5.r), border: Border.all( - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), )), child: Center(child: text16W500('View More')), ), @@ -261,15 +275,15 @@ Widget ActiveCallsTab() { width: 240.w, child: text16W400_DADADA('The Beauty and Power of Video')), // sizedBoxWidth(10.w), - Spacer(), + const Spacer(), Container( height: 35.h, width: 105.w, decoration: BoxDecoration( - color: Color(0xFF3A3A3A).withOpacity(0.6), + color: const Color(0xFF3A3A3A).withOpacity(0.6), borderRadius: BorderRadius.circular(5.r), border: Border.all( - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), ), child: Center( @@ -294,7 +308,7 @@ Widget ActiveCallsTab() { children: [ InkWell( onTap: () { - Get.to(() => PlayerWidget(), arguments: { + Get.to(() => const PlayerWidget(), arguments: { "video_url": "", }); }, @@ -303,7 +317,7 @@ Widget ActiveCallsTab() { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.r), - image: DecorationImage( + image: const DecorationImage( image: AssetImage( 'assets/images/png/Rectangle 17934.png'))), child: Center( @@ -321,8 +335,8 @@ Widget ActiveCallsTab() { children: [ CircleAvatar( radius: 23.r, - backgroundImage: - AssetImage('assets/images/png/Ellipse 1494.png'), + backgroundImage: const AssetImage( + 'assets/images/png/Ellipse 1494.png'), ), sizedBoxWidth(10.w), Expanded( @@ -406,7 +420,7 @@ Widget cardcallWidget( blur: 10, alignment: Alignment.center, border: 0.9, - linearGradient: LinearGradient( + linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -414,7 +428,7 @@ Widget cardcallWidget( Color(0xFF3A3A3A), ], ), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -429,13 +443,13 @@ Widget cardcallWidget( ), sizedBoxWidth(15.w), text18W600(text), - Spacer(), + const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: Color(0xFFFFAD31), + color: const Color(0xFFFFAD31), ), child: Center(child: text16W400_1B1B1B('Hold')), ) @@ -445,7 +459,7 @@ Widget cardcallWidget( Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(20), @@ -460,7 +474,7 @@ Widget cardcallWidget( ], ), // sizedBoxWidth(50.w), - Spacer(), + const Spacer(), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -500,13 +514,13 @@ Widget ProductWidget({required String text, required String subtext}) { end: Alignment.bottomRight, colors: [ Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xFFFFFFFF).withOpacity(0.05), ], stops: [ 0.1, 1, ]), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -545,13 +559,13 @@ Widget commoncontainer( end: Alignment.bottomRight, colors: [ Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xFFFFFFFF).withOpacity(0.05), ], stops: [ 0.1, 1, ]), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ diff --git a/lib/view/MainScreen/ShortTrade.dart b/lib/view/MainScreen/ShortTrade.dart index a8c60b3..c5a530c 100644 --- a/lib/view/MainScreen/ShortTrade.dart +++ b/lib/view/MainScreen/ShortTrade.dart @@ -1,21 +1,22 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_svg/svg.dart'; +import 'package:gap/gap.dart'; import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; -import 'package:traderscircuit/Utils/Common/CommonAppBar.dart'; import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart'; import 'package:traderscircuit/Utils/Common/CommonTabBar.dart'; import 'package:traderscircuit/Utils/Common/commonBotton.dart'; import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart'; import 'package:traderscircuit/Utils/Common/sized_box.dart'; import 'package:traderscircuit/Utils/text.dart'; -import 'package:traderscircuit/resources/routes/route_name.dart'; +import 'package:traderscircuit/controller/products_controller.dart'; +import 'package:traderscircuit/model/ProductsModel/call_recommendations_model.dart'; import 'package:traderscircuit/view/MainScreen/MainScreen.dart'; -import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart'; import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import 'package:traderscircuit/view_model/ProductsApi/products_api.dart'; class ShortTrade extends StatefulWidget { const ShortTrade({super.key}); @@ -28,6 +29,27 @@ class _ShortTradeState extends State { GlobalKey _scaffoldKey1 = GlobalKey(); List containerTexts = ["Swing Trade", "Multibagger", "Options"]; final selectedIndex = 0.obs; + ProductsController productsController = Get.put(ProductsController()); + + @override + void initState() { + productsController.isLoaded.value = true; + ProductsApi().getSwingTradeRecommendationsApi().then((value) { + productsController.swingTradeModel = + CallRecommendationsModel.fromJson(value.data); + ProductsApi().getMultibaggerRecommendationsApi().then((value) { + productsController.multibaggerModel = + CallRecommendationsModel.fromJson(value.data); + ProductsApi().getOptionsRecommendationsApi().then((value) { + productsController.optionModel = + CallRecommendationsModel.fromJson(value.data); + productsController.isLoaded.value = false; + }); + }); + }); + super.initState(); + } + @override Widget build(BuildContext context) { return WillPopScope( @@ -38,7 +60,7 @@ class _ShortTradeState extends State { child: Scaffold( key: _scaffoldKey1, backgroundColor: Colors.black, drawerEnableOpenDragGesture: false, - drawer: Container(child: SideMenu()), + drawer: const SideMenu(), extendBody: true, appBar: AppBar( scrolledUnderElevation: 0.0, @@ -83,63 +105,88 @@ class _ShortTradeState extends State { // // ), // ), // ), - body: Stack( - children: [ - CommonBlurLeft(), - CommonBlurRight(), - Stack(children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: ListView( - physics: NeverScrollableScrollPhysics(), - children: [ - sizedBoxHeight(15.h), - SizedBox( - height: 60, - width: double.infinity, - // color: Colors.amber, - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - itemCount: containerTexts.length, - itemBuilder: (context, index) { - return GestureDetector( - onTap: () { - selectedIndex.value = index; - }, - child: Row( + body: Obx( + () => Stack( + children: [ + const CommonBlurLeft(), + const CommonBlurRight(), + Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 16), + child: ListView( + physics: const NeverScrollableScrollPhysics(), + children: [ + sizedBoxHeight(15.h), + SizedBox( + height: 60, + width: double.infinity, + // color: Colors.amber, + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: containerTexts.length, + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + selectedIndex.value = index; + }, + child: Row( + children: [ + topContainer( + containerTexts[index], index), + sizedBoxWidth(10.w) + ], + ), + ); + }), + ), + sizedBoxHeight(20.h), + productsController.isLoaded.value + ? const Center( + child: CircularProgressIndicator( + color: Colors.redAccent, + ), + ) + : DefaultTabController( + length: 2, + // initialIndex: selectedIndex.value, + child: Column( children: [ - topContainer( - containerTexts[index], index), - sizedBoxWidth(10.w) + MyTabBar(), + SizedBox( + height: 700.h, + child: TabBarView( + children: [ + ActiveCallsTab( + selectedIndex.value == 0 + ? productsController + .swingTradeModel + : selectedIndex.value == 1 + ? productsController + .multibaggerModel + : productsController + .optionModel), + ExitedCallsTab( + selectedIndex.value == 0 + ? productsController + .swingTradeModel + : selectedIndex.value == 1 + ? productsController + .multibaggerModel + : productsController + .optionModel), + ], + ), + ), ], ), - ); - }), - ), - sizedBoxHeight(20.h), - DefaultTabController( - length: 2, - // initialIndex: selectedIndex.value, - child: Column( - children: [ - MyTabBar(), - SizedBox( - height: 700.h, - child: TabBarView( - children: [ - ActiveCallsTab(), - ExitedCallsTab(), - ], ), - ), - ], - ), - ), - sizedBoxHeight(20.h), - ])) - ]) - ], + sizedBoxHeight(20.h), + ])) + ]) + ], + ), ), bottomNavigationBar: bottomnavigationbar(mainController), ), @@ -184,127 +231,55 @@ class _ShortTradeState extends State { return exitApp ?? false; } - Widget ActiveCallsTab() { - return Obx(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (selectedIndex == 1 || selectedIndex == 2) _unlockbottomsheet(); - }); - return selectedIndex == 0 - ? SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: Padding( - padding: EdgeInsets.only(top: 20.h, bottom: 210.h), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - cardSwingWidget( - text: 'Indiabulls Housing Finance Ltd', + Widget ActiveCallsTab(CallRecommendationsModel callRecommendationsModel) { + return callRecommendationsModel.data!.activeCalls!.isEmpty + ? Center( + child: Column( + children: [ + const Gap(200), + text22W600("No Data Available !"), + ], + )) + : ListView.builder( + itemCount: callRecommendationsModel.data!.activeCalls!.length, + itemBuilder: (ctx, index) { + return Padding( + padding: EdgeInsets.only(top: 20.h, bottom: 5.h), + child: selectedIndex.value == 0 + ? cardSwingWidget( + image: callRecommendationsModel + .data!.activeCalls![index].stockImage!, + text: callRecommendationsModel + .data!.activeCalls![index].stockName!, amount: '₹ 196.50 - ₹ 197', - targetamount: '₹ 204', - stoploss: '₹ 190', - time: '4-5 Days'), - sizedBoxHeight(25.h), - text22W600('Content Bytes'), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 240.w, - child: text16W400_DADADA( - 'The Beauty and Power of Video')), - Spacer(), - Container( - height: 35.h, - width: 105.w, - decoration: BoxDecoration( - color: Color(0xFF3A3A3A).withOpacity(0.6), - borderRadius: BorderRadius.circular(5.r), - border: Border.all( - color: Color(0xFF3A3A3A), - )), - child: Center( - child: InkWell( - onTap: () { - Get.toNamed(RouteName.contentbytes); - }, - child: text16W500('View More'), - ), - ), - ), - ], - ), - sizedBoxHeight(20.h), - commonGlassContainer( - borderradius: 8, - width: double.infinity, - height: 330.h, - customWidget: Padding( - padding: EdgeInsets.symmetric( - vertical: 10.h, horizontal: 10.w), - child: Column( - children: [ - InkWell( - onTap: () { - Get.to(() => PlayerWidget(), arguments: { - "video_url": "", - }); - }, - child: Container( - height: 200.h, - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.r), - image: DecorationImage( - image: AssetImage( - 'assets/images/png/Rectangle 17934.png'))), - child: Center( - child: SvgPicture.asset( - 'assets/images/svg/gridicons_play.svg', - height: 56.h, - width: 56.w, - ), - ), - ), - ), - sizedBoxHeight(20.h), - Row( - children: [ - CircleAvatar( - radius: 23.r, - backgroundImage: AssetImage( - 'assets/images/png/Ellipse 1494.png'), - ), - sizedBoxWidth(10.w), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - text18W500('Week of 21st February 2024'), - // sizedBoxHeight(10.h), - text12W400_979797( - '20k views . 2 days ago'), - ], - ), - ) - ], - ) - ], - ), - ), - ), - ], - ), - ), - ) - : selectedIndex == 1 - ? Column( - children: [], - ) - : Column( - children: [], - ); - }); + targetamount: + '₹ ${callRecommendationsModel.data!.activeCalls![index].targetPrice}', + stoploss: + '₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}', + time: + '${callRecommendationsModel.data!.activeCalls![index].duration}', + action: callRecommendationsModel + .data!.activeCalls![index].actionData!.name!, + ) + : selectedIndex.value == 1 + ? cardMultibaggerWidget( + text: callRecommendationsModel + .data!.activeCalls![index].stockName!, + price: + "₹ ${callRecommendationsModel.data!.activeCalls![index].buyPrice}", + date: callRecommendationsModel + .data!.activeCalls![index].createdAt!, + returns: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + stoploss: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + duration: callRecommendationsModel + .data!.activeCalls![index].duration!, + pdfname: "Download Pdf", + ) + : SizedBox(), + ); + }); } void _unlockbottomsheet() { @@ -331,7 +306,7 @@ class _ShortTradeState extends State { onTap: () {}, ), - SizedBox( + const SizedBox( height: 100, ) ], @@ -343,7 +318,7 @@ class _ShortTradeState extends State { ); } - Widget ExitedCallsTab() { + Widget ExitedCallsTab(CallRecommendationsModel callRecommendationsModel) { List> cardSwing = [ { 'text': 'Indiabulls Housing Finance Ltd', @@ -436,22 +411,38 @@ class _ShortTradeState extends State { children: [ sizedBoxHeight(20.h), Obx(() { - return selectedIndex == 0 - ? Column( - children: List.generate(cardSwing.length, (index) { - return Column( + return selectedIndex.value == 0 + ? callRecommendationsModel.data!.exitedCalls!.isEmpty + ? Center( + child: Column( children: [ - cardSwingWidget( - text: cardSwing[index]['text']!, - amount: cardSwing[index]['amount']!, - targetamount: cardSwing[index]['targetamount']!, - stoploss: cardSwing[index]['stoploss']!, - time: cardSwing[index]['time']!), - sizedBoxHeight(20.h) + const Gap(200), + text22W600("No Data Available !"), ], - ); - }), - ) + )) + : ListView.builder( + itemCount: + callRecommendationsModel.data!.exitedCalls!.length, + itemBuilder: (ctx, index) { + return Padding( + padding: EdgeInsets.only(top: 20.h, bottom: 5.h), + child: cardSwingWidget( + image: callRecommendationsModel + .data!.exitedCalls![index].stockImage!, + text: callRecommendationsModel + .data!.exitedCalls![index].stockName!, + amount: '₹ 196.50 - ₹ 197', + targetamount: + '₹ ${callRecommendationsModel.data!.exitedCalls![index].targetPrice}', + stoploss: + '₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}', + time: + '${callRecommendationsModel.data!.exitedCalls![index].duration}', + action: callRecommendationsModel + .data!.exitedCalls![index].actionData!.name!, + ), + ); + }) : selectedIndex == 1 ? Column( children: @@ -526,7 +517,7 @@ class _ShortTradeState extends State { blur: 10, alignment: Alignment.center, border: 0.9, - linearGradient: LinearGradient( + linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -534,7 +525,7 @@ class _ShortTradeState extends State { Color(0xFF3A3A3A), ], ), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -552,13 +543,13 @@ class _ShortTradeState extends State { ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), - Spacer(), + const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: Color(0xFFFFAD31), + color: const Color(0xFFFFAD31), ), child: Center(child: text14W600_1B1B1B('Hold')), ) @@ -568,7 +559,7 @@ class _ShortTradeState extends State { Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(18), @@ -684,7 +675,7 @@ class _ShortTradeState extends State { blur: 10, alignment: Alignment.center, border: 0.9, - linearGradient: LinearGradient( + linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -692,7 +683,7 @@ class _ShortTradeState extends State { Color(0xFF3A3A3A), ], ), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -710,13 +701,13 @@ class _ShortTradeState extends State { ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), - Spacer(), + const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: Color(0xFFFFAD31), + color: const Color(0xFFFFAD31), ), child: Center(child: text14W600_1B1B1B('Hold')), ) @@ -726,7 +717,7 @@ class _ShortTradeState extends State { Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(18), @@ -819,11 +810,13 @@ class _ShortTradeState extends State { } Widget cardSwingWidget({ + required String image, required String text, required String amount, required String targetamount, required String stoploss, required String time, + required String action, }) { return commonGlassContainer( width: double.infinity, @@ -842,7 +835,7 @@ class _ShortTradeState extends State { blur: 10, alignment: Alignment.center, border: 0.9, - linearGradient: LinearGradient( + linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -850,7 +843,7 @@ class _ShortTradeState extends State { Color(0xFF3A3A3A), ], ), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -859,20 +852,22 @@ class _ShortTradeState extends State { ], ), child: Center( - child: Image.asset('assets/images/png/Teal.png'), + child: CachedNetworkImage(imageUrl: image), ), ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), - Spacer(), + const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: Color(0xFFFFAD31), + color: action == "Buy" + ? const Color(0xFF00FF19) + : const Color(0xFFFFAD31), ), - child: Center(child: text14W600_1B1B1B('Hold')), + child: Center(child: text14W600_1B1B1B(action)), ) ], ), @@ -880,7 +875,7 @@ class _ShortTradeState extends State { Container( width: double.infinity, height: 1.h, - color: Color(0xFF3A3A3A), + color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(20), @@ -945,7 +940,7 @@ class _ShortTradeState extends State { width: 126.w, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: Color(0Xff6C0000), + color: const Color(0Xff6C0000), ), child: Center(child: text16W500(text)), ) diff --git a/lib/view/Sidemenu/Sidemenu.dart b/lib/view/Sidemenu/Sidemenu.dart index bf91a5c..fd140ad 100644 --- a/lib/view/Sidemenu/Sidemenu.dart +++ b/lib/view/Sidemenu/Sidemenu.dart @@ -21,7 +21,6 @@ class _SideMenuState extends State { @override void initState() { // TODO: implement initState - GetProfile().GetProfileAPI(); super.initState(); } @@ -132,9 +131,7 @@ class _SideMenuState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - text18W400( - //ProfileObj!.data!.userName ?? - ""), + text18W400(ProfileObj!.data!.userName ?? ""), sizedBoxHeight(4.h), text18W400('My Profile'), ], diff --git a/lib/view/Sidemenu/contactUs/contact_us_details.dart b/lib/view/Sidemenu/contactUs/contact_us_details.dart index 03b25b7..71b22fe 100644 --- a/lib/view/Sidemenu/contactUs/contact_us_details.dart +++ b/lib/view/Sidemenu/contactUs/contact_us_details.dart @@ -65,10 +65,29 @@ class _ContactUsDetailsScreenState extends State { child: Form( key: queriesForm, child: Scaffold( - appBar: CommonAppbar( - height: 75, - titleTxt: "", - customActionWidget: text16W400(""), + appBar: AppBar( + scrolledUnderElevation: 0.0, + backgroundColor: Colors.black, + elevation: 0, + leadingWidth: 56.w, + leading: Padding( + padding: EdgeInsets.only(left: 16.w, top: 20.h), + child: GestureDetector( + onTap: () { + contactUsController.isTicketClosed + ? Get.back(result: true) + : Get.back(); + }, + child: Padding( + padding: EdgeInsets.only(left: 8.w), + child: Icon( + Icons.arrow_back_ios, + color: Colors.white, + size: 25.r, + ), + ), + ), + ), ), backgroundColor: Colors.black, extendBody: true, diff --git a/lib/view/Sidemenu/contactUs/contact_us_main.dart b/lib/view/Sidemenu/contactUs/contact_us_main.dart index 80066f9..365c3a7 100644 --- a/lib/view/Sidemenu/contactUs/contact_us_main.dart +++ b/lib/view/Sidemenu/contactUs/contact_us_main.dart @@ -1,3 +1,216 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:gap/gap.dart'; +import 'package:get/get.dart'; +import 'package:traderscircuit/controller/contact_us_controller.dart'; +import 'package:traderscircuit/model/ContactUsModel/contact_us_cat_model.dart'; +import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart'; +import 'package:traderscircuit/resources/routes/route_name.dart'; +import 'package:traderscircuit/view_model/ContactUsApi/contact_us_api.dart'; +import '../../../Utils/Common/CommonAppbar.dart'; +import '../../../Utils/Common/commonBotton.dart'; +import '../../../Utils/text.dart'; +import '../../../view_model/ProfileAPI/GetProfileApi.dart'; +import '../../onBoarding/splashScreen1.dart'; +import 'create_ticket_bottom_sheet.dart'; + +class ContactUsMainScreen extends StatefulWidget { + const ContactUsMainScreen({super.key}); + + @override + State createState() => _ContactUsMainScreenState(); +} + +class _ContactUsMainScreenState extends State { + ContactUsController contactUsController = Get.put(ContactUsController()); + + RxBool isEmpty = false.obs; + @override + void initState() { + contactUsController.isLoading.value == true; + ContactUsApi().getContactUsCategoriesData().then((value) { + contactUsController.contactCatModel = + ContactUsCatModel.fromJson(value.data); + + ContactUsApi().getContactUsData().then((value) { + Map responseData = + Map.from(value.data); + if (responseData["message"] == "Data not found.") { + isEmpty.value = true; + } else { + contactUsController.allC.value = 0; + contactUsController.openC.value = 0; + contactUsController.closeC.value = 0; + contactUsController.resolvedC.value = 0; + + contactUsController.contactModel = + ContactUsModel.fromJson(value.data); + for (var a in contactUsController.contactModel.data!) { + if (a.status == 1) { + contactUsController.openC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 2) { + contactUsController.closeC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 3) { + contactUsController.resolvedC.value += 1; + contactUsController.allC.value += 1; + } + } + } + contactUsController.isLoading.value = false; + }); + }); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Obx(() => DefaultTabController( + length: 4, + child: Scaffold( + appBar: CommonAppbar( + height: 75, + titleTxt: "", + customActionWidget: text16W400(""), + ), + backgroundColor: Colors.black, + extendBody: true, + bottomNavigationBar: Padding( + padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 40), + child: SizedBox( + width: Get.width, + child: kycBtn( + text: "Create Ticket", + onTap: () { + contactUsController.attachmentFileList.clear(); + contactUsController.attachmentPathNameList.clear(); + CreateTicketBottomSheet().bottomSheet(context); + }, + bgClr: const Color(0xFF6C0000), + borderClr: const Color(0xFF990000), + ), + ), + ), + body: Stack( + children: [ + const CommonBlurLeft(), + const CommonBlurRight(), + Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 16), + child: contactUsController.isLoading.value + ? const Center( + child: CircularProgressIndicator( + color: Colors.redAccent, + )) + : isEmpty.value + ? Center(child: text18W800("No Data Available")) + : ListView( + physics: const NeverScrollableScrollPhysics(), + children: [ + text25W600("Contact Us"), + const Gap(20), + text16W400( + "Hi ${ProfileObj!.data!.userName}"), + text16W400("We are here to help you"), + const Gap(12), + TabBar( + tabAlignment: TabAlignment.start, + labelStyle: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.w400, + fontFamily: "hiragino", + ), + isScrollable: true, + labelColor: Colors.white, + unselectedLabelColor: + const Color(0xFF464646), + indicatorColor: const Color(0xFF6C0000), + indicatorSize: TabBarIndicatorSize.tab, + unselectedLabelStyle: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.w500, + fontFamily: "hiragino", + ), + tabs: [ + Tab( + text: + "All Tickets (${contactUsController.allC.value})"), + Tab( + text: + "Open Tickets (${contactUsController.openC.value})"), + Tab( + text: + "Closed (${contactUsController.closeC.value})"), + Tab( + text: + "Resolved (${contactUsController.resolvedC.value})"), + ], + ), + SizedBox( + height: 0.5.sh, + child: TabBarView(children: [ + ListView.builder( + itemCount: contactUsController + .contactModel.data!.length, + itemBuilder: (ctx, index) { + return ticketCardWidget( + index, "ALL"); + }), + ListView.builder( + itemCount: contactUsController + .contactModel.data!.length, + itemBuilder: (ctx, index) { + return contactUsController + .contactModel + .data![index] + .status == + 1 + ? ticketCardWidget( + index, "OPEN") + : const SizedBox(); + }), + ListView.builder( + itemCount: contactUsController + .contactModel.data!.length, + itemBuilder: (ctx, index) { + return contactUsController + .contactModel + .data![index] + .status == + 2 + ? ticketCardWidget( + index, "CLOSED") + : const SizedBox(); + }), + ListView.builder( + itemCount: contactUsController + .contactModel.data!.length, + itemBuilder: (ctx, index) { + return contactUsController + .contactModel + .data![index] + .status == + 3 + ? ticketCardWidget( + index, "RESOLVED") + : const SizedBox(); + }), + ]), + ) + ], + )), + ]), + ], + ), + ), + )); + } +} + Widget ticketCardWidget(index, type) { ContactUsController contactUsController = Get.put(ContactUsController()); return InkWell( diff --git a/lib/view/login/VerifyOtp.dart b/lib/view/login/VerifyOtp.dart index 978cbe5..4c918d6 100644 --- a/lib/view/login/VerifyOtp.dart +++ b/lib/view/login/VerifyOtp.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -44,6 +46,7 @@ class _VerifyOTPState extends State { if (isValid!) { SharedPreferences prefs = await SharedPreferences.getInstance(); Utils.loader(); + // print("PLAYER ID ==> ${prefs.getString("playerId")}"); Map updata = { "mobile_number": phonenumber.toString(), "otp": pincode.text, @@ -51,6 +54,7 @@ class _VerifyOTPState extends State { }; final resp = await VerifyNumberAPI(updata).verifynumberApi(); if (resp.status == ResponseStatus.SUCCESS) { + log(resp.data.toString()); Get.back(); isVendorExist = resp.data["data"]["vendor_account_exist"]; isProfileUpdated = resp.data["data"]["user_data"]["profile_updated"]; @@ -101,7 +105,7 @@ class _VerifyOTPState extends State { } else { Get.back(); String? message = resp.message; - Utils.showToast("$message"); + Utils.showToast(message); } } } @@ -109,21 +113,22 @@ class _VerifyOTPState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: CommonAppbar(titleTxt: "Verify OTP"), + appBar: const CommonAppbar(titleTxt: "Verify OTP"), backgroundColor: Colors.black, extendBody: true, body: Stack( children: [ - CommonBlurLeft(), - CommonBlurRight(), + const CommonBlurLeft(), + const CommonBlurRight(), Stack( children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 16), child: Form( key: _otpform, child: ListView( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), // mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -165,7 +170,7 @@ class _VerifyOTPState extends State { fieldHeight: 60.h, fieldWidth: 60.w, ), - animationDuration: Duration(milliseconds: 300), + animationDuration: const Duration(milliseconds: 300), enableActiveFill: true, controller: pincode, onCompleted: (v) { diff --git a/lib/view/onBoarding/splashScreen.dart b/lib/view/onBoarding/splashScreen.dart index 0dd2054..4260a28 100644 --- a/lib/view/onBoarding/splashScreen.dart +++ b/lib/view/onBoarding/splashScreen.dart @@ -6,6 +6,7 @@ import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:onesignal_flutter/onesignal_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; @@ -46,7 +47,10 @@ class _SplashScreenState extends State void initState() { super.initState(); checkInternet(); - + OneSignal.shared + .setSubscriptionObserver((OSSubscriptionStateChanges changes) async { + print(changes.to.userId!.toString()); + }); Future.delayed(Duration(seconds: 2), () async { if (_connectionStatus == ConnectivityResult.none) { var result = await Get.to(NoInternet()); diff --git a/lib/view_model/ProductsApi/products_api.dart b/lib/view_model/ProductsApi/products_api.dart new file mode 100644 index 0000000..f363892 --- /dev/null +++ b/lib/view_model/ProductsApi/products_api.dart @@ -0,0 +1,75 @@ +import 'dart:developer'; + +import 'package:traderscircuit/Utils/api_urls.dart'; +import 'package:traderscircuit/Utils/base_manager.dart'; +import 'package:traderscircuit/data/network/network_api_services.dart'; + +class ProductsApi { + Future> getListOfProducts() async { + final response = await NetworkApiServices() + .getApi(ApiUrls.getListOfProducts, isAuth: true); + log(response.data.toString()); + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + return response; + } else { + return ResponseData( + responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } + + Future> getOptionsRecommendationsApi() async { + final response = await NetworkApiServices() + .getApi(ApiUrls.getOptionsRecommendations, isAuth: true); + // log(response.data.toString()); + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + return response; + } else { + return ResponseData( + responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } + + Future> getSwingTradeRecommendationsApi() async { + final response = await NetworkApiServices() + .getApi(ApiUrls.getSwingTradeRecommendations, isAuth: true); + // log(response.data.toString()); + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + return response; + } else { + return ResponseData( + responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } + + Future> getMultibaggerRecommendationsApi() async { + final response = await NetworkApiServices() + .getApi(ApiUrls.getMultibaggerRecommendations, isAuth: true); + // log(response.data.toString()); + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + return response; + } else { + return ResponseData( + responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } +}