From de61f5563d30d8fd8e584262040ffbaaa0fb85ca Mon Sep 17 00:00:00 2001 From: Rajshinde046 Date: Wed, 8 May 2024 15:58:31 +0530 Subject: [PATCH] home api --- lib/Utils/Common/CommonTabBar.dart | 3 +- lib/Utils/api_urls.dart | 3 + lib/controller/contact_us_controller.dart | 7 +- lib/model/HomeModel/home_model.dart | 436 ++++++++++++++++ lib/view/MainScreen/ExploreUnseen.dart | 103 ---- lib/view/MainScreen/HomeScreen.dart | 575 ++++++++++++---------- lib/view_model/HomeApi/home_api.dart | 25 + 7 files changed, 786 insertions(+), 366 deletions(-) create mode 100644 lib/model/HomeModel/home_model.dart create mode 100644 lib/view_model/HomeApi/home_api.dart diff --git a/lib/Utils/Common/CommonTabBar.dart b/lib/Utils/Common/CommonTabBar.dart index 73c5dcc..0159a35 100644 --- a/lib/Utils/Common/CommonTabBar.dart +++ b/lib/Utils/Common/CommonTabBar.dart @@ -17,6 +17,7 @@ class MyTabBar extends StatelessWidget { color: const Color(0xff6C0000), borderRadius: BorderRadius.circular(5), ), + isScrollable: false, dividerColor: Colors.transparent, labelStyle: TextStyle( fontSize: 18.sp, @@ -38,4 +39,4 @@ class MyTabBar extends StatelessWidget { ]), ); } -} \ No newline at end of file +} diff --git a/lib/Utils/api_urls.dart b/lib/Utils/api_urls.dart index c4f6719..0c5c043 100644 --- a/lib/Utils/api_urls.dart +++ b/lib/Utils/api_urls.dart @@ -71,4 +71,7 @@ class ApiUrls { "${base}get-swing-trade-recommendations"; static String getMultibaggerRecommendations = "${base}get-multibagger-recommendations"; + + //Home + static String getHome = "${base}home-page-details"; } diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index de3bd96..9fe599c 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -19,7 +19,7 @@ class ContactUsController extends GetxController { //contact us page controller RxList attachmentFileList = [File("")].obs; RxList attachmentPathNameList = [""].obs; - RxList contactUsDetailsChatContent = [].obs; + RxList contactUsDetailsChatContent = [].obs; //contact us details page controller RxList attachmentFileDetailsList = [File("")].obs; RxList attachmentPathNameDetailsList = [""].obs; @@ -35,8 +35,5 @@ class ContactUsController extends GetxController { return DateFormat("dd MMM yyyy, hh:mm a").format(dateTime.toLocal()); } - - RxList contactUsDetailsChatContent = [].obs; + // RxList contactUsDetailsChatContent = [].obs; } - - diff --git a/lib/model/HomeModel/home_model.dart b/lib/model/HomeModel/home_model.dart new file mode 100644 index 0000000..b848f95 --- /dev/null +++ b/lib/model/HomeModel/home_model.dart @@ -0,0 +1,436 @@ +class HomeModel { + String? status; + int? statusCode; + String? message; + Data? data; + + HomeModel({this.status, this.statusCode, this.message, this.data}); + + HomeModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = new Map(); + data['status'] = this.status; + data['status_code'] = this.statusCode; + data['message'] = this.message; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? exploreTheUnseenActiveCalls; + List? exploreTheUnseenExitedCalls; + UserData? userData; + List? products; + ContentByteVideo? contentByteVideo; + + Data( + {this.exploreTheUnseenActiveCalls, + this.exploreTheUnseenExitedCalls, + this.userData, + this.products, + this.contentByteVideo}); + + Data.fromJson(Map json) { + if (json['explore_the_unseen_active_calls'] != null) { + exploreTheUnseenActiveCalls = []; + json['explore_the_unseen_active_calls'].forEach((v) { + exploreTheUnseenActiveCalls! + .add(new ExploreTheUnseenActiveCalls.fromJson(v)); + }); + } + if (json['explore_the_unseen_exited_calls'] != null) { + exploreTheUnseenExitedCalls = []; + json['explore_the_unseen_exited_calls'].forEach((v) { + exploreTheUnseenExitedCalls! + .add(new ExploreTheUnseenExitedCalls.fromJson(v)); + }); + } + userData = json['user_data'] != null + ? new UserData.fromJson(json['user_data']) + : null; + if (json['products'] != null) { + products = []; + json['products'].forEach((v) { + products!.add(new Products.fromJson(v)); + }); + } + contentByteVideo = json['content_byte_video'] != null + ? new ContentByteVideo.fromJson(json['content_byte_video']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.exploreTheUnseenActiveCalls != null) { + data['explore_the_unseen_active_calls'] = + this.exploreTheUnseenActiveCalls!.map((v) => v.toJson()).toList(); + } + if (this.exploreTheUnseenExitedCalls != null) { + data['explore_the_unseen_exited_calls'] = + this.exploreTheUnseenExitedCalls!.map((v) => v.toJson()).toList(); + } + if (this.userData != null) { + data['user_data'] = this.userData!.toJson(); + } + if (this.products != null) { + data['products'] = this.products!.map((v) => v.toJson()).toList(); + } + if (this.contentByteVideo != null) { + data['content_byte_video'] = this.contentByteVideo!.toJson(); + } + return data; + } +} + +class ExploreTheUnseenActiveCalls { + int? id; + int? manageProductXid; + int? recommendationActionsXid; + String? stockName; + String? instrumentKey; + String? stockImage; + String? qty; + String? duration; + String? currentPrice; + String? buyPrice; + String? targetPrice; + String? stopLoss; + int? isSendRecommendationNow; + String? scheduleDateTime; + String? createdAt; + ProductData? productData; + ActionData? actionData; + + ExploreTheUnseenActiveCalls( + {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}); + + ExploreTheUnseenActiveCalls.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 + ? new ProductData.fromJson(json['product_data']) + : null; + actionData = json['action_data'] != null + ? new ActionData.fromJson(json['action_data']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['manage_product_xid'] = this.manageProductXid; + data['recommendation_actions_xid'] = this.recommendationActionsXid; + data['stock_name'] = this.stockName; + data['instrument_key'] = this.instrumentKey; + data['stock_image'] = this.stockImage; + data['qty'] = this.qty; + data['duration'] = this.duration; + data['current_price'] = this.currentPrice; + data['buy_price'] = this.buyPrice; + data['target_price'] = this.targetPrice; + data['stop_loss'] = this.stopLoss; + data['is_send_recommendation_now'] = this.isSendRecommendationNow; + data['schedule_date_time'] = this.scheduleDateTime; + data['created_at'] = this.createdAt; + if (this.productData != null) { + data['product_data'] = this.productData!.toJson(); + } + if (this.actionData != null) { + data['action_data'] = this.actionData!.toJson(); + } + return data; + } +} + +class ExploreTheUnseenExitedCalls { + int? id; + int? manageProductXid; + int? recommendationActionsXid; + String? stockName; + String? instrumentKey; + String? stockImage; + String? qty; + String? duration; + String? currentPrice; + String? buyPrice; + String? targetPrice; + String? stopLoss; + int? isSendRecommendationNow; + String? scheduleDateTime; + String? createdAt; + ProductData? productData; + ActionData? actionData; + + ExploreTheUnseenExitedCalls( + {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}); + + ExploreTheUnseenExitedCalls.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 + ? new ProductData.fromJson(json['product_data']) + : null; + actionData = json['action_data'] != null + ? new ActionData.fromJson(json['action_data']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['manage_product_xid'] = this.manageProductXid; + data['recommendation_actions_xid'] = this.recommendationActionsXid; + data['stock_name'] = this.stockName; + data['instrument_key'] = this.instrumentKey; + data['stock_image'] = this.stockImage; + data['qty'] = this.qty; + data['duration'] = this.duration; + data['current_price'] = this.currentPrice; + data['buy_price'] = this.buyPrice; + data['target_price'] = this.targetPrice; + data['stop_loss'] = this.stopLoss; + data['is_send_recommendation_now'] = this.isSendRecommendationNow; + data['schedule_date_time'] = this.scheduleDateTime; + data['created_at'] = this.createdAt; + if (this.productData != null) { + data['product_data'] = this.productData!.toJson(); + } + if (this.actionData != null) { + data['action_data'] = this.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 = new Map(); + data['id'] = this.id; + data['product_name'] = this.productName; + data['is_active'] = this.isActive; + data['created_at'] = this.createdAt; + return data; + } +} + +class ActionData { + int? id; + String? name; + int? isActive; + String? 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 = new Map(); + data['id'] = this.id; + data['name'] = this.name; + data['is_active'] = this.isActive; + data['created_at'] = this.createdAt; + return data; + } +} + +class UserData { + int? id; + String? firstName; + String? lastName; + String? userName; + String? profilePhoto; + String? isActive; + String? createdAt; + + UserData( + {this.id, + this.firstName, + this.lastName, + this.userName, + this.profilePhoto, + this.isActive, + this.createdAt}); + + UserData.fromJson(Map json) { + id = json['id']; + firstName = json['first_name']; + lastName = json['last_name']; + userName = json['user_name']; + profilePhoto = json['profile_photo']; + isActive = json['is_active']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['first_name'] = this.firstName; + data['last_name'] = this.lastName; + data['user_name'] = this.userName; + data['profile_photo'] = this.profilePhoto; + data['is_active'] = this.isActive; + data['created_at'] = this.createdAt; + return data; + } +} + +class Products { + int? id; + String? title; + String? createdAt; + + Products({this.id, this.title, this.createdAt}); + + Products.fromJson(Map json) { + id = json['id']; + title = json['title']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['created_at'] = this.createdAt; + return data; + } +} + +class ContentByteVideo { + int? id; + String? contentType; + String? title; + String? description; + String? tags; + String? file; + int? categoryId; + String? image; + String? isActive; + String? createdAt; + + ContentByteVideo( + {this.id, + this.contentType, + this.title, + this.description, + this.tags, + this.file, + this.categoryId, + this.image, + this.isActive, + this.createdAt}); + + ContentByteVideo.fromJson(Map json) { + id = json['id']; + contentType = json['content_type']; + title = json['title']; + description = json['description']; + tags = json['tags']; + file = json['file']; + categoryId = json['category_id']; + image = json['image']; + isActive = json['is_active']; + createdAt = json['created_at']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['content_type'] = this.contentType; + data['title'] = this.title; + data['description'] = this.description; + data['tags'] = this.tags; + data['file'] = this.file; + data['category_id'] = this.categoryId; + data['image'] = this.image; + data['is_active'] = this.isActive; + data['created_at'] = this.createdAt; + return data; + } +} diff --git a/lib/view/MainScreen/ExploreUnseen.dart b/lib/view/MainScreen/ExploreUnseen.dart index 9db2068..270b10f 100644 --- a/lib/view/MainScreen/ExploreUnseen.dart +++ b/lib/view/MainScreen/ExploreUnseen.dart @@ -1,17 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/svg.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/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/view/MainScreen/MainScreen.dart'; -import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; class ExploreUnseen extends StatefulWidget { @@ -32,25 +26,6 @@ class _ExploreUnseenState extends State { extendBody: true, appBar: CommonAppbar(titleTxt: ''), - // AppBar( - // scrolledUnderElevation: 0.0, - // backgroundColor: Colors.black, - // elevation: 0, - // automaticallyImplyLeading: false, - // titleSpacing: 0, - // leading: InkWell( - // onTap: () { - // _scaffoldKey1.currentState?.openDrawer(); - // }, - // child: Center( - // child: Image.asset( - // 'assets/images/png/menu.png', - // height: 15.h, - // width: 20.w, - // ), - // ), - // ), - // ), body: Stack(children: [ CommonBlurLeft(), CommonBlurRight(), @@ -83,84 +58,6 @@ class _ExploreUnseenState extends State { amount: '₹ 453 - ₹234', pdfname: 'Download Pdf'), sizedBoxHeight(30.h), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text22W600('Content Bytes'), - sizedBoxHeight(8.w), - 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: 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: [ - 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), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 250.w, - child: - text18W500('Week of 21st February 2024')), - // sizedBoxHeight(10.h), - text12W400_979797('20k views . 2 days ago'), - ], - ) - ], - ) - ], - ), - )) - ], - ), ], ); } diff --git a/lib/view/MainScreen/HomeScreen.dart b/lib/view/MainScreen/HomeScreen.dart index 59ded30..85130e4 100644 --- a/lib/view/MainScreen/HomeScreen.dart +++ b/lib/view/MainScreen/HomeScreen.dart @@ -10,11 +10,13 @@ import 'package:traderscircuit/Utils/Common/CommonTabBar.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/model/HomeModel/home_model.dart'; import 'package:traderscircuit/resources/routes/route_name.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/HomeApi/home_api.dart'; import '../../view_model/ProfileAPI/GetProfileApi.dart'; @@ -28,12 +30,19 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { GlobalKey _scaffoldKey1 = GlobalKey(); RxString userName = "User".obs; + HomeModel homeModel = HomeModel(); + + RxBool isApiCalling = true.obs; @override void initState() { GetProfile().GetProfileAPI().then((value) { userName.value = ProfileObj!.data!.userName ?? "User"; }); + HomeApi().getHomeData().then((value) { + homeModel = HomeModel.fromJson(value.data); + }); + isApiCalling.value = false; super.initState(); } @@ -87,126 +96,251 @@ class _HomeScreenState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: ListView( - physics: const BouncingScrollPhysics(), - children: [ - sizedBoxHeight(20.h), - Obx( - () => Text( - "Welcome $userName", - style: TextStyle( - color: Colors.white, - fontSize: 24.sp, - fontFamily: 'hiragino', - fontWeight: FontWeight.w500), - ), - ), - sizedBoxHeight(25.h), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( + child: isApiCalling.value + ? Center( + child: CircularProgressIndicator(), + ) + : ListView( + physics: const BouncingScrollPhysics(), children: [ - commoncontainer( - width: 195.w, - text: 'NIFTY', - amount: '22,286.95', - rate: '+304.15 (+1.38%)'), - sizedBoxWidth(10.w), - commoncontainer( - width: 240.w, - text: 'BANKNIFTY', - amount: '22,286.95', - rate: '+896.10 (+1.94%)'), - ], - ), - ), - sizedBoxHeight(30.h), - Container( - width: double.infinity, - height: 1.h, - color: const Color(0xFF3A3A3A), - ), - sizedBoxHeight(30.h), - text22W500('View our products'), - sizedBoxHeight(30.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ProductWidget( - text: 'Options', subtext: 'Recommendation'), - ProductWidget( - text: 'Multibagger', subtext: 'Recommendation') - ], - ), - sizedBoxHeight(15.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ProductWidget( - text: 'Swing Trade', subtext: 'Recommendation'), - ProductWidget( - text: 'OP + MB + ST', subtext: 'Recommendation'), - ], - ), - sizedBoxHeight(25.h), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset('assets/images/svg/Vector (2).svg'), - sizedBoxWidth(10.w), - text18W500('UNLOCK NOW!'), - ], - ), - sizedBoxHeight(25.h), - Container( - width: double.infinity, - height: 1.h, - color: const Color(0xFF3A3A3A), - ), - sizedBoxHeight(25.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - text22W600('Explore The Unseen'), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.exploreUnseen); - }, - child: Container( - height: 35.h, - width: 105.w, - decoration: BoxDecoration( - color: const Color(0xFF3A3A3A).withOpacity(0.6), - borderRadius: BorderRadius.circular(5.r), - border: Border.all( - color: const Color(0xFF3A3A3A), - )), - child: Center(child: text16W500('View More')), + sizedBoxHeight(20.h), + Obx( + () => Text( + "Welcome $userName", + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + fontFamily: 'hiragino', + fontWeight: FontWeight.w500), + ), ), - ), - ], - ), - sizedBoxHeight(35.h), - DefaultTabController( - length: 2, - child: Column( - children: [ - MyTabBar(), - SizedBox( - height: 700.h, - child: TabBarView( + sizedBoxHeight(25.h), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( children: [ - ActiveCallsTab(), - ExitedCallsTab(), + commoncontainer( + width: 195.w, + text: 'NIFTY', + amount: '22,286.95', + rate: '+304.15 (+1.38%)'), + sizedBoxWidth(10.w), + commoncontainer( + width: 240.w, + text: 'BANKNIFTY', + amount: '22,286.95', + rate: '+896.10 (+1.94%)'), ], ), ), + sizedBoxHeight(30.h), + Container( + width: double.infinity, + height: 1.h, + color: const Color(0xFF3A3A3A), + ), + sizedBoxHeight(30.h), + text22W500('View our products'), + sizedBoxHeight(30.h), + SizedBox( + height: 210, + child: GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: + 2, // number of items in each row + mainAxisSpacing: 8.0, // spacing between rows + crossAxisSpacing: + 8.0, // spacing between columns + childAspectRatio: 2.2, + ), + itemCount: homeModel.data!.products!.length, + itemBuilder: (context, index) { + return ProductWidget( + text: homeModel.data!.products! + .elementAt(index) + .title!, + subtext: "recommendation"); + }, + ), + ), + sizedBoxHeight(25.h), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/images/svg/Vector (2).svg'), + sizedBoxWidth(10.w), + text18W500('UNLOCK NOW!'), + ], + ), + sizedBoxHeight(25.h), + Container( + width: double.infinity, + height: 1.h, + color: const Color(0xFF3A3A3A), + ), + sizedBoxHeight(25.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + text22W600('Explore The Unseen'), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.exploreUnseen); + }, + child: Container( + height: 35.h, + width: 105.w, + decoration: BoxDecoration( + color: const Color(0xFF3A3A3A) + .withOpacity(0.6), + borderRadius: BorderRadius.circular(5.r), + border: Border.all( + color: const Color(0xFF3A3A3A), + )), + child: Center(child: text16W500('View More')), + ), + ), + ], + ), + sizedBoxHeight(35.h), + DefaultTabController( + length: 2, + child: Column( + children: [ + MyTabBar(), + SizedBox( + height: 250.h, + child: TabBarView( + children: [ + ActiveCallsTab(), + ExitedCallsTab(), + ], + ), + ), + ], + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text22W600('Content Bytes'), + sizedBoxHeight(8.w), + Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 240.w, + child: text16W400_DADADA( + 'The Beauty and Power of Video')), + // sizedBoxWidth(10.w), + const Spacer(), + Container( + height: 35.h, + width: 105.w, + decoration: BoxDecoration( + color: const Color(0xFF3A3A3A) + .withOpacity(0.6), + borderRadius: BorderRadius.circular(5.r), + border: Border.all( + color: const 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(() => const PlayerWidget(), + arguments: { + "video_url": "", + }); + }, + child: Container( + height: 200.h, + width: double.infinity, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(8.r), + image: DecorationImage( + image: NetworkImage(homeModel + .data! + .contentByteVideo! + .image ?? + ""), + ), + ), + child: Center( + child: SvgPicture.asset( + 'assets/images/svg/gridicons_play.svg', + height: 56.h, + width: 56.w, + ), + ), + ), + ), + sizedBoxHeight(20.h), + Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + CircleAvatar( + radius: 23.r, + backgroundImage: NetworkImage( + homeModel + .data! + .contentByteVideo! + .title ?? + ""), + ), + sizedBoxWidth(10.w), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + text18W500(homeModel + .data! + .contentByteVideo! + .title ?? + ""), + // sizedBoxHeight(10.h), + text12W400_979797( + '20k views . 2 days ago'), + ], + ), + ) + ], + ) + ], + ), + )) + ], + ), ], ), - ), - ], - ), ) ]) ], @@ -253,156 +387,77 @@ class _HomeScreenState extends State { }); return exitApp ?? false; } -} -Widget ActiveCallsTab() { - return Column( - children: [ - sizedBoxHeight(30.h), - cardcallWidget( - text: 'Trident Ltd', amount: '₹ 453 - ₹234', pdfname: 'Download Pdf'), - sizedBoxHeight(30.h), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text22W600('Content Bytes'), - sizedBoxHeight(8.w), - Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 240.w, - child: text16W400_DADADA('The Beauty and Power of Video')), - // sizedBoxWidth(10.w), - const Spacer(), - Container( - height: 35.h, - width: 105.w, - decoration: BoxDecoration( - color: const Color(0xFF3A3A3A).withOpacity(0.6), - borderRadius: BorderRadius.circular(5.r), - border: Border.all( - color: const 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(() => const PlayerWidget(), arguments: { - "video_url": "", - }); - }, - child: Container( - height: 200.h, - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.r), - image: const 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( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CircleAvatar( - radius: 23.r, - backgroundImage: const 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'), - ], - ), - ) - ], - ) - ], - ), - )) - ], - ), - ], - ); -} - -Widget ExitedCallsTab() { - List> cardcall = [ - { - 'text': 'Trident Ltd', - 'amount': '₹ 453 - ₹234', - 'pdfname': 'Download Pdf', - }, - { - 'text': 'Trident Ltd', - 'amount': '₹ 453 - ₹234', - 'pdfname': 'Download Pdf', - }, - { - 'text': 'Trident Ltd', - 'amount': '₹ 453 - ₹234', - 'pdfname': 'Download Pdf', - }, - ]; - - return SingleChildScrollView( - child: Column( + Widget ActiveCallsTab() { + return Column( children: [ sizedBoxHeight(30.h), - Column( - children: List.generate(cardcall.length, (index) { - return Column( - children: [ - cardcallWidget( - text: cardcall[index]['text']!, - amount: cardcall[index]['amount']!, - pdfname: cardcall[index]['pdfname']!), - sizedBoxHeight(20.h) - ], - ); - }), - ), + cardcallWidget( + action: homeModel.data!.exploreTheUnseenActiveCalls!.first + .recommendationActionsXid == + 1 + ? "Buy" + : homeModel.data!.exploreTheUnseenActiveCalls!.first + .recommendationActionsXid == + 2 + ? "Sell" + : homeModel.data!.exploreTheUnseenActiveCalls!.first + .recommendationActionsXid == + 3 + ? "Hold" + : homeModel.data!.exploreTheUnseenActiveCalls!.first + .recommendationActionsXid == + 4 + ? "Exit" + : "", + text: homeModel.data!.exploreTheUnseenActiveCalls!.first.stockName!, + amount: + "₹ ${homeModel.data!.exploreTheUnseenActiveCalls!.first.buyPrice!}", + pdfname: 'Download Pdf'), + sizedBoxHeight(30.h), ], - ), - ); + ); + } + + Widget ExitedCallsTab() { + return Column( + children: [ + sizedBoxHeight(30.h), + homeModel.data!.exploreTheUnseenExitedCalls!.isEmpty || + homeModel.data!.exploreTheUnseenExitedCalls == null + ? text14W300("No Data") + : Column( + children: List.generate( + homeModel.data!.exploreTheUnseenExitedCalls!.length, + (index) { + return Column( + children: [ + cardcallWidget( + action: "Hold", + text: homeModel.data!.exploreTheUnseenExitedCalls! + .elementAt(index) + .stockName ?? + "", + amount: homeModel.data!.exploreTheUnseenExitedCalls! + .elementAt(index) + .buyPrice ?? + "", + pdfname: "Download Pdf"), + sizedBoxHeight(20.h) + ], + ); + }), + ) + ], + ); + } } Widget cardcallWidget( - {required String text, required String amount, required String pdfname}) { + {required String text, + required String amount, + required String pdfname, + required String action}) { return commonGlassContainer( width: double.infinity, height: 176.h, @@ -449,9 +504,15 @@ Widget cardcallWidget( height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: const Color(0xFFFFAD31), + color: action == "Buy" + ? Colors.green + : action == "Sell" + ? Colors.red + : action == "Hold" + ? const Color(0xFFFFAD31) + : Colors.white, ), - child: Center(child: text16W400_1B1B1B('Hold')), + child: Center(child: text16W400_1B1B1B(action)), ) ], ), diff --git a/lib/view_model/HomeApi/home_api.dart b/lib/view_model/HomeApi/home_api.dart new file mode 100644 index 0000000..b2cd611 --- /dev/null +++ b/lib/view_model/HomeApi/home_api.dart @@ -0,0 +1,25 @@ +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 HomeApi { + Future> getHomeData() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getHome, + ); + 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; + } +} \ No newline at end of file