My Subscription UI and api integration done

This commit is contained in:
priyanka
2024-04-16 00:56:42 -07:00
parent a010948b58
commit a28660be21
7 changed files with 352 additions and 31 deletions

View File

@@ -0,0 +1,49 @@
class SubscriptionDataModel {
bool? success;
String? message;
Result? result;
SubscriptionDataModel({this.success, this.message, this.result});
SubscriptionDataModel.fromJson(Map<String, dynamic> json) {
success = json['success'];
message = json['message'];
result =
json['result'] != null ? new Result.fromJson(json['result']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['success'] = this.success;
data['message'] = this.message;
if (this.result != null) {
data['result'] = this.result!.toJson();
}
return data;
}
}
class Result {
int? id;
String? utmSource;
String? startDate;
String? endDate;
Result({this.id, this.utmSource, this.startDate, this.endDate});
Result.fromJson(Map<String, dynamic> json) {
id = json['id'];
utmSource = json['utm_source'];
startDate = json['start_date'];
endDate = json['end_date'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['utm_source'] = this.utmSource;
data['start_date'] = this.startDate;
data['end_date'] = this.endDate;
return data;
}
}

View File

@@ -1,10 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'package:get/get.dart';
import 'package:gsp_app/repository/endpoints.dart';
import 'package:http/http.dart' as http;
import 'package:rxdart/rxdart.dart';
import '../../api/base_manager.dart';
import '../../api/network_api.dart';

View File

@@ -0,0 +1,22 @@
import '../../api/ResponseManager.dart';
import '../../api/network_api.dart';
import '../../modals/subscriptionDataModel.dart';
SubscriptionDataModel? subscriptionObj;
class SubscriptionDataService {
Future<ResponseData<dynamic>> fetchSubscriptionData() async {
final response = await NetworkApi()
.getApi('https://gsf.betadelivery.com/api/userSubscriptionData');
if (response.data['success'] == true) {
subscriptionObj = SubscriptionDataModel.fromJson(response.data);
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.SUCCESS);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
}

View File

@@ -33,10 +33,6 @@ class _BlogMainState extends State<BlogMain> with TickerProviderStateMixin {
// final CategoryViewModel categoryViewModel = Get.put(CategoryViewModel());
StreamController<SearchModel> blogsController = StreamController();
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -308,15 +304,21 @@ class _NewsBodyState extends State<NewsBody> {
physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
var updatedAtTime = searchArticle!
.result![index].updatedAt;
DateTime updatedAt =
DateTime.parse(updatedAtTime!);
Duration difference =
DateTime.now().difference(updatedAt);
String formattedDifference = DateFormat()
.add_Hm()
.format(updatedAt);
String formatDateTime(
String dateTimeString) {
// Parse the datetime string
DateTime dateTime =
DateTime.parse(dateTimeString);
String formattedDateTime =
DateFormat('MMM dd, yyyy hh:mm a')
.format(dateTime);
formattedDateTime += ' IST';
return formattedDateTime;
}
return cardList(
articleName: searchArticle!
.result![index].articleName ??
@@ -324,7 +326,10 @@ class _NewsBodyState extends State<NewsBody> {
thumbnailimg: searchArticle!
.result![index].thumbnailPath ??
'',
updatedTime: formattedDifference,
updatedTime: formatDateTime(
searchArticle!
.result![index].updatedAt ??
''),
categoryId:
searchArticle!.result![index].id ??
0,
@@ -335,7 +340,10 @@ class _NewsBodyState extends State<NewsBody> {
searchArticle!.result![index].tags,
InnerDescription: searchArticle!
.result![index].description,
Innerformattedtime: formattedDifference,
Innerformattedtime: formatDateTime(
searchArticle!
.result![index].updatedAt ??
''),
// articleid: widget.category.articles![index],
);
}))
@@ -496,7 +504,9 @@ cardList({
color: const Color(0xff707070),
),
),
child: Image.network(thumbnailimg, fit: BoxFit.fill),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: Image.network(thumbnailimg, fit: BoxFit.cover)),
// Image.asset(
// 'assets/image/avatar.png',

View File

@@ -83,6 +83,7 @@ class _FeedBackState extends State<FeedBack> {
}
final isValid = _formkey.currentState?.validate();
if (isValid!) {
FocusScope.of(context).unfocus();
Map<String, String> updata = {
"user_id": '',
"message": _textarea.text,
@@ -282,8 +283,8 @@ class _FeedBackState extends State<FeedBack> {
// const Spacer(),
InkWell(
onTap: () async {
FocusScope.of(context).unfocus();
_feedbackbutton();
// FocusScope.of(context).unfocus();
await _feedbackbutton();
},
child: Container(
width: Get.width * 0.3,

View File

@@ -15,6 +15,7 @@ import 'package:gsp_app/views/pages/profile/pages/profile_page.dart';
import 'package:gsp_app/views/pages/quiz/quiz_home.dart';
import 'package:gsp_app/views/pages/signIn/complete_profile_before_sign_in.dart';
import 'package:gsp_app/views/pages/signIn/sign_in.dart';
import 'package:gsp_app/views/pages/subscription/my_subscription.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../view_model/global_controller.dart';
import '../../view_model/home_controller.dart';
@@ -194,13 +195,12 @@ class _AppDrawerState extends State<AppDrawer> {
false),
const SizedBox(height: 15),
menuWidget(
'news_articles',
'News & Articles',
() => Get.to(
() => const BlogMain(),
),
false
),
'news_articles',
'News & Articles',
() => Get.to(
() => const BlogMain(),
),
false),
const SizedBox(height: 15),
// menuWidget(
// 'instagram',
@@ -275,6 +275,13 @@ class _AppDrawerState extends State<AppDrawer> {
() => const ContactUs(),
);
}, false),
const SizedBox(height: 15),
menuWidget('phone', 'My Subscription', () {
Get.back();
Get.to(
() => const MySubscription(),
);
}, false),
// const SizedBox(height: 15),
// menuWidget('phone', 'Test', () { Get.back();

View File

@@ -0,0 +1,238 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import '../../../repository/services/subscriptionDataService.dart';
import '../../../view_model/global_controller.dart';
import '../../components/appbar.dart';
import '../../theme.dart';
class MySubscription extends StatefulWidget {
const MySubscription({super.key});
@override
State<MySubscription> createState() => _MySubscriptionState();
}
class _MySubscriptionState extends State<MySubscription> {
late Future myfuture;
String? startDate;
String? enddate;
@override
void initState() {
myfuture = SubscriptionDataService().fetchSubscriptionData();
super.initState();
}
GlobalController globalController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: CustomAppBars(titleHead: 'Subscription plan'),
),
body: FutureBuilder(
future: myfuture,
builder: (context, snapshot) {
if (snapshot.data == null) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [CircularProgressIndicator()],
),
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Center(
child: Text(
'${snapshot.error} occured',
style: TextStyle(fontSize: 18),
),
);
}
}
startDate = subscriptionObj!.result!.startDate;
String formattedStartDate =
DateFormat('dd/MM/yyyy').format(DateTime.parse(startDate!));
enddate = subscriptionObj!.result!.endDate;
String formattedEndDate =
DateFormat('dd/MM/yyyy').format(DateTime.parse(enddate!));
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
SizedBox(
height: 60,
),
Container(
// height: 400,
width: double.infinity,
decoration: BoxDecoration(
color: !globalController.darkMode.value
? ColorConstants.kWhite
: const Color(0xff212121),
boxShadow: [
BoxShadow(
spreadRadius: 2,
blurRadius: 10,
color: !globalController.darkMode.value
? ColorConstants.kBlack.withOpacity(0.3)
: ColorConstants.kWhite.withOpacity(0),
)
],
borderRadius: BorderRadius.circular(30),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
subscriptionObj!.result!.utmSource ?? '',
style: TextStyle(
fontSize: 25,
color: !globalController.darkMode.value
? ColorConstants.kBlack
: ColorConstants.kWhite,
fontFamily: 'SFPRO',
),
),
SizedBox(
height: 30,
),
rowTile(
text:
'Unlimited access to live virtual fitness classes led by certified trainers.'),
SizedBox(
height: 20,
),
rowTile(
text:
'Access to a library of workout videos covering various fitness levels and goals.'),
SizedBox(
height: 20,
),
rowTile(
text:
'Progress tracking to monitor your achievements and stay motivated.'),
SizedBox(
height: 20,
),
rowTile(
text:
'Basic nutrition guidance and meal planning tips.'),
SizedBox(
height: 20,
),
],
),
),
),
SizedBox(
height: 25,
),
Container(
// height: 40,
width: double.infinity,
decoration: BoxDecoration(
color: !globalController.darkMode.value
? ColorConstants.kWhite
: const Color(0xff212121),
boxShadow: [
BoxShadow(
spreadRadius: 2,
blurRadius: 10,
color: !globalController.darkMode.value
? ColorConstants.kBlack.withOpacity(0.3)
: ColorConstants.kWhite.withOpacity(0),
)
],
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 16, 20, 16),
child: Center(
child: Row(
children: [
Icon(
Icons.calendar_month_outlined,
color: Color(0xFFBBF046),
),
SizedBox(
width: 10,
),
Expanded(
child: Text(
// 'Membership till : 15/04/2024 - 15/10/2024',
'Membership till : $formattedStartDate - $formattedEndDate',
style: TextStyle(
fontSize: 14,
height: 2.2,
color: !globalController.darkMode.value
? ColorConstants.kBlack
: ColorConstants.kWhite,
fontFamily: 'SFPRO',
),
),
),
],
),
),
)),
],
),
));
}),
);
}
Widget rowTile({required String text}) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
children: [
SizedBox(
height: 10,
),
Container(
height: 20,
width: 20,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xffBBF046)),
child: Icon(
Icons.check,
size: 15,
color: Color(0xFF000000),
),
),
],
),
SizedBox(
width: 10,
),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: 14,
height: 2.2,
color: !globalController.darkMode.value
? ColorConstants.kBlack
: ColorConstants.kWhite,
fontFamily: 'SFPRO',
),
),
),
],
);
}
}