Merge pull request #124 from WDI-Ideas/createcommunity
some fixes for community details page and network api services to che…
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart' hide Response;
|
||||
import 'package:regroup/Global.dart';
|
||||
import 'package:regroup/Common/base_manager.dart';
|
||||
import 'package:regroup/Utils/dialogs.dart';
|
||||
import 'package:regroup/resources/routes/route_name.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -16,8 +18,8 @@ class NetworkApiServices {
|
||||
Dio dio = Dio();
|
||||
final controllerEntryPoint = Get.put(EntryPointController());
|
||||
|
||||
String basicAuth = 'Basic ${base64.encode(
|
||||
utf8.encode('RegroupUserName:71%@L%es^bUX94`J9XT*@bh,._WWM{\$%^^&&'))}';
|
||||
String basicAuth =
|
||||
'Basic ${base64.encode(utf8.encode('RegroupUserName:71%@L%es^bUX94`J9XT*@bh,._WWM{\$%^^&&'))}';
|
||||
|
||||
Future<ResponseData> getApi(String url, {bool optionalpar = false}) async {
|
||||
if (kDebugMode) {
|
||||
@@ -45,12 +47,48 @@ class NetworkApiServices {
|
||||
: Options(
|
||||
headers: {
|
||||
'authorization': basicAuth,
|
||||
'access-token': token
|
||||
'access-token':
|
||||
token
|
||||
},
|
||||
),
|
||||
);
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
on Exception catch (e) {
|
||||
// log(e.toString());
|
||||
if (e is DioException) {
|
||||
log(e.response.toString());
|
||||
if (e.response == null) {
|
||||
return ResponseData<dynamic>(
|
||||
'Oops something Went Wrong, Please try again!',
|
||||
ResponseStatus.FAILED,
|
||||
);
|
||||
}
|
||||
if (e.response!.statusCode == 401) {
|
||||
if (e.response!.data['message'] == 'Invalid token') {
|
||||
// prefs.remove('access-token');
|
||||
// await prefs.clear();
|
||||
// Get.offNamed(RouteName.loginScreen);
|
||||
utils.showToast('Please login again');
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
'Oops something Went Wrong, Please try again!',
|
||||
ResponseStatus.FAILED,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
if (e.response!.statusCode == 403) {
|
||||
if (e.response!.data['message'] is List) {
|
||||
return ResponseData<dynamic>(
|
||||
e.response!.data['message'][0]!, ResponseStatus.FAILED,
|
||||
data: e.response!.data);
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
e.response!.data['message'], ResponseStatus.FAILED,
|
||||
data: e.response!.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseData<dynamic>(
|
||||
'Oops something Went Wrong', ResponseStatus.FAILED);
|
||||
}
|
||||
@@ -174,7 +212,9 @@ class NetworkApiServices {
|
||||
},
|
||||
)
|
||||
: Options(
|
||||
headers: {'authorization': basicAuth, 'access-token': token},
|
||||
headers: {'authorization': basicAuth, 'access-token':
|
||||
token
|
||||
},
|
||||
),
|
||||
);
|
||||
log(response.toString());
|
||||
@@ -188,13 +228,22 @@ class NetworkApiServices {
|
||||
);
|
||||
}
|
||||
if (e.response!.statusCode == 401) {
|
||||
prefs.remove('token');
|
||||
prefs.remove('refreshToken');
|
||||
if (e.response!.data['message'] == 'Invalid token') {
|
||||
prefs.remove('access-token');
|
||||
await prefs.clear();
|
||||
Get.offNamed(RouteName.loginScreen);
|
||||
utils.showToast('Please login again');
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
'Oops something Went Wrong, Please try again!',
|
||||
ResponseStatus.FAILED,
|
||||
);
|
||||
}
|
||||
// Get.toNamed(RouteName.login);
|
||||
return ResponseData<dynamic>(
|
||||
'Oops something Went Wrong, Please try again!',
|
||||
ResponseStatus.FAILED,
|
||||
);
|
||||
// return ResponseData<dynamic>(
|
||||
// 'Oops something Went Wrong, Please try again!',
|
||||
// ResponseStatus.FAILED,
|
||||
// );
|
||||
}
|
||||
if (e.response!.statusCode == 403) {
|
||||
if (e.response!.data['message'] is List) {
|
||||
|
||||
@@ -19,7 +19,6 @@ class Group extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _GroupState extends State<Group> {
|
||||
|
||||
int id = Get.arguments["id"];
|
||||
bool iscommunity = Get.arguments["iscommunity"];
|
||||
|
||||
@@ -40,7 +39,7 @@ class _GroupState extends State<Group> {
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: iscommunity == true
|
||||
? FutureBuilder(
|
||||
future: Getcommunity().getCommunitygroups(1),
|
||||
future: Getcommunity().getCommunitygroups(id),
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.data == null) {
|
||||
return const Column(
|
||||
|
||||
@@ -29,6 +29,7 @@ class _CommunityMembersState extends State<CommunityMembers> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
print(communityid);
|
||||
var updata = communityid;
|
||||
var updata2 = "";
|
||||
Getcommunity().getCommunityMemberssearch(updata, updata2,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -333,9 +334,26 @@ class _AddGroupState extends State<AddGroup> {
|
||||
backgroundImage: AssetImage('assets/images/png/img2.png'),
|
||||
radius: 20.r,
|
||||
)
|
||||
: CircleAvatar(
|
||||
backgroundImage: NetworkImage(imagePath),
|
||||
:
|
||||
// CircleAvatar(
|
||||
// backgroundImage: NetworkImage(imagePath),
|
||||
// radius: 20.r,
|
||||
// ),
|
||||
CircleAvatar(
|
||||
backgroundImage: CachedNetworkImageProvider(imagePath),
|
||||
radius: 20.r,
|
||||
child: CachedNetworkImage(
|
||||
cacheKey: index.toString(),
|
||||
maxHeightDiskCache: 100,
|
||||
maxWidthDiskCache: 100,
|
||||
imageUrl: imagePath,
|
||||
placeholder: (context, url) => Container(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25.r,
|
||||
),
|
||||
),
|
||||
),
|
||||
sizedBoxWidth(10.w),
|
||||
Expanded(
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -237,23 +239,23 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
],
|
||||
),
|
||||
sizedBoxHeight(30.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
text13w400_FCFCFC("Show Details"),
|
||||
sizedBoxWidth(4.w),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
additionalContent = !additionalContent!;
|
||||
setState(() {});
|
||||
},
|
||||
child: Image.asset(
|
||||
InkWell(
|
||||
onTap: () {
|
||||
additionalContent = !additionalContent!;
|
||||
setState(() {});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
text13w400_FCFCFC("Show Details"),
|
||||
sizedBoxWidth(4.w),
|
||||
Image.asset(
|
||||
"assets/images/png/Vector 8.png",
|
||||
height: 8.h,
|
||||
width: 20.w,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (additionalContent == true)
|
||||
Column(
|
||||
@@ -314,28 +316,36 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
customWidget: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
sizedBoxWidth(16.w),
|
||||
stackContainers(
|
||||
number: "+2",
|
||||
containerImages: [
|
||||
"assets/images/png/cimg3.png",
|
||||
"assets/images/png/cimg2.png",
|
||||
"assets/images/png/cimg3.png",
|
||||
"assets/images/png/cimg2.png",
|
||||
],
|
||||
),
|
||||
sizedBoxWidth(90.w),
|
||||
text16w400_white('7 members'),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.arrow_forward,
|
||||
size: 20.sp,
|
||||
color: Colors.white,
|
||||
),
|
||||
sizedBoxWidth(16.w),
|
||||
],
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.communitymembers,
|
||||
arguments: {
|
||||
'communityid': CommunityId,
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
sizedBoxWidth(16.w),
|
||||
stackContainers(
|
||||
number: "+2",
|
||||
containerImages: [
|
||||
"assets/images/png/cimg3.png",
|
||||
"assets/images/png/cimg2.png",
|
||||
"assets/images/png/cimg3.png",
|
||||
"assets/images/png/cimg2.png",
|
||||
],
|
||||
),
|
||||
sizedBoxWidth(90.w),
|
||||
text16w400_white('7 members'),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.arrow_forward,
|
||||
size: 20.sp,
|
||||
color: Colors.white,
|
||||
),
|
||||
sizedBoxWidth(16.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -343,7 +353,11 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
sizedBoxHeight(20.h),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.addgroup);
|
||||
// Get.toNamed(RouteName.addgroup);
|
||||
Get.toNamed(RouteName.group, arguments: {
|
||||
'id': CommunityId,
|
||||
'iscommunity': true,
|
||||
});
|
||||
},
|
||||
child: commonGlassUI(
|
||||
width: double.infinity,
|
||||
|
||||
Reference in New Issue
Block a user