Skip to content

Commit

Permalink
feature updates and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nixrajput committed Sep 10, 2022
1 parent b6a5c62 commit c1e4b2e
Show file tree
Hide file tree
Showing 34 changed files with 1,538 additions and 387 deletions.
78 changes: 57 additions & 21 deletions lib/apis/providers/api_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,25 @@ class ApiProvider {
return response;
}

Future<http.StreamedResponse> uploadProfilePicture(
Future<http.Response> uploadProfilePicture(
String token,
http.MultipartFile multiPartFile,
Map<String, dynamic> body,
) async {
final request = http.MultipartRequest(
"POST",
final response = await _client.post(
Uri.parse(baseUrl! + AppUrls.uploadProfilePicEndpoint),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
},
body: jsonEncode(body),
);

request.headers.addAll({
"content-type": "application/json",
"authorization": "Bearer $token",
});

request.files.add(multiPartFile);

final response = await request.send();

return response;
}

Future<http.Response> deleteProfilePicture(String token) async {
final response = await _client.delete(
Uri.parse(baseUrl! + AppUrls.deleteProfilePicEndpoint),
Uri.parse('${baseUrl!}${AppUrls.deleteProfilePicEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -162,7 +157,7 @@ class ApiProvider {
Future<http.Response> updateProfile(
String token, Map<String, dynamic> body) async {
final response = await _client.put(
Uri.parse(baseUrl! + AppUrls.updateProfileEndpoint),
Uri.parse('${baseUrl!}${AppUrls.updateProfileEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -176,7 +171,7 @@ class ApiProvider {
Future<http.Response> changePassword(
String token, Map<String, dynamic> body) async {
final response = await _client.post(
Uri.parse(baseUrl! + AppUrls.changePasswordEndpoint),
Uri.parse('${baseUrl!}${AppUrls.changePasswordEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -192,7 +187,7 @@ class ApiProvider {
Map<String, dynamic> body,
) async {
final response = await _client.post(
Uri.parse(baseUrl! + AppUrls.changeEmailEndpoint),
Uri.parse('${baseUrl!}${AppUrls.changeEmailEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -208,7 +203,7 @@ class ApiProvider {
Map<String, dynamic> body,
) async {
final response = await _client.put(
Uri.parse(baseUrl! + AppUrls.changeEmailEndpoint),
Uri.parse('${baseUrl!}${AppUrls.changeEmailEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -224,7 +219,7 @@ class ApiProvider {
Map<String, dynamic> body,
) async {
final response = await _client.post(
Uri.parse(baseUrl! + AppUrls.addChangePhoneEndpoint),
Uri.parse('${baseUrl!}${AppUrls.addChangePhoneEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -240,7 +235,7 @@ class ApiProvider {
Map<String, dynamic> body,
) async {
final response = await _client.put(
Uri.parse(baseUrl! + AppUrls.addChangePhoneEndpoint),
Uri.parse('${baseUrl!}${AppUrls.addChangePhoneEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -253,7 +248,7 @@ class ApiProvider {

Future<http.Response> verifyPassword(String token, String password) async {
final response = await _client.post(
Uri.parse(baseUrl! + AppUrls.verifyPasswordEndpoint),
Uri.parse('${baseUrl!}${AppUrls.verifyPasswordEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
Expand All @@ -264,6 +259,47 @@ class ApiProvider {
return response;
}

Future<http.Response> deactivateAccount(
String token,
Map<String, dynamic> body,
) async {
final response = await _client.post(
Uri.parse('${baseUrl!}${AppUrls.deactivateAccountEndpoint}'),
headers: {
"content-type": "application/json",
"authorization": "Bearer $token",
},
body: jsonEncode(body),
);

return response;
}

Future<http.Response> sendReactivateAccountOtp(
Map<String, dynamic> body) async {
final response = await _client.post(
Uri.parse('${baseUrl!}${AppUrls.reactivateAccountEndpoint}'),
headers: {
"content-type": "application/json",
},
body: jsonEncode(body),
);

return response;
}

Future<http.Response> reactivateAccount(Map<String, dynamic> body) async {
final response = await _client.put(
Uri.parse('${baseUrl!}${AppUrls.reactivateAccountEndpoint}'),
headers: {
"content-type": "application/json",
},
body: jsonEncode(body),
);

return response;
}

/// Post ---------------------------------------------------------------------
Future<http.Response> createPost(
Expand Down
2 changes: 1 addition & 1 deletion lib/constants/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class ColorValues {
static const Color darkDividerColor = Color(0xff707070);
static const Color lightDividerColor = Color(0xffc2c2c2);

static const Color lightBodyTextColor = Color(0xFF323232);
static const Color lightBodyTextColor = Color(0xFF282828);
static const Color lightSubtitleTextColor = Color(0xFF737373);
static const Color darkBodyTextColor = Color(0xFFDCDCDC);
static const Color darkSubtitleTextColor = Color(0xFFA0A0A0);
Expand Down
2 changes: 2 additions & 0 deletions lib/constants/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ abstract class StaticData {
"rental clerk",
"repair worker",
"reporter",
"research scholar",
"reservation clerk",
"residential advisor",
"resort desk clerk",
"respiratory therapist",
Expand Down
3 changes: 3 additions & 0 deletions lib/constants/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class StringValues {
static const forgotPassword = 'Forgot Password';
static const resetPassword = 'Reset Password';
static const verifyAccount = 'Verify Account';
static const reactivateAccount = 'Reactivate Account';
static const name = 'Name';
static const next = 'Next';
static const firstName = 'First Name';
Expand Down Expand Up @@ -141,6 +142,8 @@ abstract class StringValues {
static const usernameNotAvailable = 'Username not available.';
static const userIdNotFound = 'User Id not found.';
static const privateAccountWarning = 'This Account is private';
static const deactivatedAccountWarning = 'This Account is deactivated';
static const noImageVideoSelectedWarning = 'No image or video selected';
static const followAccountText =
'Follow this account to see their photos and videos.';
static const notFollowingWarning = 'You are not following the user.';
Expand Down
6 changes: 4 additions & 2 deletions lib/constants/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ abstract class AppUrls {
static const String deleteCommentEndpoint = '/delete-comment';

static const String profileDetailsEndpoint = '/me';
static const String uploadProfilePicEndpoint = '/upload-avatar';
static const String deleteProfilePicEndpoint = '/delete-avatar';
static const String uploadProfilePicEndpoint = '/upload-profile-picture';
static const String deleteProfilePicEndpoint = '/remove-profile-picture';
static const String changePasswordEndpoint = '/change-password';
static const String updateProfileEndpoint = '/update-profile';
static const String checkUsernameEndpoint = '/check-username';
Expand All @@ -34,6 +34,8 @@ abstract class AppUrls {
static const String addChangePhoneEndpoint = '/add-change-phone';
static const String changeEmailEndpoint = '/change-email';
static const String verifyPasswordEndpoint = '/verify-password';
static const String deactivateAccountEndpoint = '/deactivate-account';
static const String reactivateAccountEndpoint = '/reactivate-account';

static const String saveLoginInfoEndpoint = '/save-device-info';
static const String getLoginInfoEndpoint = '/get-device-info';
Expand Down
7 changes: 5 additions & 2 deletions lib/helpers/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ abstract class AppUtils {
alignment: Alignment.center,
child: Material(
type: MaterialType.card,
color: Theme.of(Get.context!).scaffoldBackgroundColor,
color: Theme.of(Get.context!).dialogBackgroundColor,
borderRadius: BorderRadius.all(
Radius.circular(Dimens.eight),
),
Expand All @@ -134,6 +134,7 @@ abstract class AppUtils {
),
),
barrierDismissible: barrierDismissible,
barrierColor: ColorValues.blackColor.withOpacity(0.5),
);
}

Expand Down Expand Up @@ -206,6 +207,8 @@ abstract class AppUtils {
Padding(
padding: Dimens.edgeInsets8_0,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: children,
),
Expand Down Expand Up @@ -251,7 +254,7 @@ abstract class AppUtils {
snackStyle: SnackStyle.FLOATING,
messageText: Text(
message.toCapitalized(),
style: AppStyles.style16Normal.copyWith(
style: AppStyles.style14Normal.copyWith(
color: renderTextColor(type),
),
),
Expand Down
13 changes: 1 addition & 12 deletions lib/modules/app_update/app_update_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ class AppUpdateView extends StatelessWidget {
data: logic.changelog,
),
),
Dimens.boxHeight16,
RichText(
text: TextSpan(
text:
'A newer version of the app is available. To use this app, download the latest version.',
style: AppStyles.style14Normal.copyWith(
color:
Theme.of(Get.context!).textTheme.bodyText1!.color,
),
),
),
Dimens.boxHeight20,
NxOutlinedButton(
label: 'Update Now'.toTitleCase(),
Expand All @@ -88,7 +77,7 @@ class AppUpdateView extends StatelessWidget {
Theme.of(Get.context!).textTheme.bodyText1!.color,
padding: Dimens.edgeInsets0_8,
width: Dimens.screenWidth,
height: Dimens.thirtySix,
height: Dimens.fourty,
labelStyle: AppStyles.style14Normal.copyWith(
color: Theme.of(Get.context!).scaffoldBackgroundColor,
),
Expand Down
9 changes: 9 additions & 0 deletions lib/modules/auth/bindings/reactivate_account_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:get/get.dart';
import 'package:social_media_app/modules/auth/controllers/reactivate_account_controller.dart';

class ReactivateAccountBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(ReactivateAccountController.new);
}
}
13 changes: 9 additions & 4 deletions lib/modules/auth/controllers/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class LoginController extends GetxController {

final FocusScopeNode focusNode = FocusScopeNode();
final _showPassword = true.obs;

final _accountStatus = ''.obs;
final _isLoading = false.obs;

bool get isLoading => _isLoading.value;

String get accountStatus => _accountStatus.value;

bool get showPassword => _showPassword.value;

void _clearLoginTextControllers() {
Expand Down Expand Up @@ -75,8 +77,6 @@ class LoginController extends GetxController {

final decodedData = jsonDecode(utf8.decode(response.bodyBytes));

AppUtils.printLog(decodedData);

if (response.statusCode == 200) {
_auth.setLoginData = AuthResponse.fromJson(decodedData);

Expand Down Expand Up @@ -112,9 +112,14 @@ class LoginController extends GetxController {
return;
});
} else {
AppUtils.closeDialog();
AppUtils.printLog(decodedData);
_accountStatus.value = decodedData['accountStatus'];
_isLoading.value = false;
update();
AppUtils.closeDialog();
if (_accountStatus.value == "deactivated") {
RouteManagement.goToReactivateAccountView();
}
AppUtils.showSnackBar(
decodedData[StringValues.message],
StringValues.error,
Expand Down
Loading

0 comments on commit c1e4b2e

Please sign in to comment.