Skip to content

Commit

Permalink
Onboarding overflow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Thesmader committed Apr 27, 2020
1 parent eb1ade1 commit 61905a5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
63 changes: 33 additions & 30 deletions gogrocy/lib/core/services/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const String signUp = baseUrl + "signup";
const String verifyUser = baseUrl + "verifyUser";
const String addAddress = baseUrl + "add_address";
const String cartList = baseUrl + 'getCartItems';
const String editCart=baseUrl+ "add_to_cart";
const String getAddress=baseUrl+"getAddress";
const String orderRequest=baseUrl+"placeOrder";
const String getOrders=baseUrl+"getorders";
const String editCart = baseUrl + "add_to_cart";
const String getAddress = baseUrl + "getAddress";
const String orderRequest = baseUrl + "placeOrder";
const String getOrders = baseUrl + "getorders";

class Apis {
final SharedPrefsService _sharedPrefsService = locator<SharedPrefsService>();
Expand Down Expand Up @@ -111,14 +111,19 @@ class Apis {
print("login via sign up success");
if (user.jwt != null) {
print("LOGIN " + user.jwt);
await verifyUserApi(user.jwt);
await addAddressApi(
name: name,
locality: locality,
city: city,
contact: mobile,
pinCode: zip,
jwt: user.jwt,
Future.delayed(
Duration(milliseconds: 10),
() async {
await verifyUserApi(user.jwt);
await addAddressApi(
name: name,
locality: locality,
city: city,
contact: mobile,
pinCode: zip,
jwt: user.jwt,
);
},
);
} else {
print("JWT FAIL: ACCOUNT NOT VALIDATED");
Expand Down Expand Up @@ -168,19 +173,20 @@ class Apis {
(print("Network failure"));
}

Future<bool> placeOrder(
{@required String address_id}) async {
Map<String,String>body={
"address_id":address_id,
Future<bool> placeOrder({@required String address_id}) async {
Map<String, String> body = {
"address_id": address_id,
};
String jwt=await _sharedPrefsService.getJWT();
String jwt = await _sharedPrefsService.getJWT();
var client = new http.Client();
bool connectionState = await checkStatus();
if (connectionState) //TODO: Add a proper else return
{
var response = await client.post(orderRequest, headers: {
'Authorization': 'Bearer $jwt',
},body: body);
{
var response = await client.post(orderRequest,
headers: {
'Authorization': 'Bearer $jwt',
},
body: body);
return true;
} else
return false;
Expand Down Expand Up @@ -225,24 +231,22 @@ class Apis {
(print("Network failure"));
}

Future<Orders> getOrders() async{
Future<Orders> getOrders() async {
var client = new http.Client();
bool connectionState = await checkStatus();
String jwt=await _sharedPrefsService.getJWT();
String jwt = await _sharedPrefsService.getJWT();
if (connectionState) //TODO: Add a proper else return
{
{
var response = await client.post(getAddress, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer $jwt',
});
return json.decode(response.body);
} else
(print("Network failure"));
print("Network failure");
}



Future<cart_list> getCartList() async {
var client = new http.Client();
bool connectionState = await checkStatus();
Expand All @@ -256,7 +260,7 @@ class Apis {
});
return cart_list.fromJson(json.decode(response.body));
} else
(print("Network failure"));
print("Network failure");
}

Future<bool> checkStatus() async {
Expand All @@ -279,8 +283,7 @@ class Apis {
if ((json.decode(result.body))["success"]) {
print("VERIFIED USER");
return true;
}
else
} else
return false;
}
}
4 changes: 2 additions & 2 deletions gogrocy/lib/ui/widgets/onboarding_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class OnBoardingWidget extends StatelessWidget {
Padding(
padding: EdgeInsets.only(top: 0.021 * constants.screenHeight),
child: SizedBox(
width: 203 * (2.550/2.002),
height: 40.0 * (2.550/2.002),
width: 203 * constants.scaleRatio,
height: 40.0 * constants.scaleRatio,
child: Text(
'The widest selection of home essentials just a few taps away',
textAlign: TextAlign.center,
Expand Down

0 comments on commit 61905a5

Please sign in to comment.