-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from fanzru/staging
Bump Main for v0.10
- Loading branch information
Showing
18 changed files
with
626 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:dio/dio.dart'; | ||
import 'package:mobile/model/komentar.dart'; | ||
import 'package:mobile/model/profile_secure.dart'; | ||
import 'package:mobile/model/user.dart'; | ||
|
||
Future<Komentar> postKomentar(int reviewId, String komentar) async { | ||
var profile = await SecureProfile.getStorage(); | ||
var formData = FormData.fromMap({"komentar": komentar}); | ||
try { | ||
var response = await Dio() | ||
.post("https://travelliu.yaudahlah.my.id/api/komentar/$reviewId", | ||
options: Options( | ||
headers: { | ||
'Authorization': 'Bearer ${profile.getApiKey()}', | ||
"Accept": "application/json", | ||
}, | ||
), | ||
data: formData); | ||
var data = response.data; | ||
var user = User.empty(name: profile.name!); | ||
return Komentar(id: data["id"] as int, komentar: komentar, user: user); | ||
} on DioError catch (e) { | ||
if (e.response != null) { | ||
var response = e.response!; | ||
if (response.statusCode == 401) { | ||
await profile.setLoggedOut(); | ||
return Future.error("Session expired"); | ||
} | ||
if (response.statusCode == 400) { | ||
return Future.error(response.data); | ||
} | ||
} | ||
return Future.error("Gagal untuk mempost review"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:mobile/model/user.dart'; | ||
|
||
class Komentar { | ||
final int id; | ||
final String komentar; | ||
User? user; | ||
|
||
Komentar({required this.id, required this.komentar, this.user}); | ||
|
||
factory Komentar.fromJson(Map<String, dynamic> json) { | ||
var user = User.empty(id: json["user"]["id"], name: json["user"]["name"]); | ||
return Komentar(id: json["id"], komentar: json["komentar"], user: user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
mobile/lib/screen/_global/components/shimmer/detail_review_shimmer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mobile/screen/_global/components/shimmer/shimmer_container.dart'; | ||
|
||
class ShimmerDetailReview extends StatelessWidget { | ||
const ShimmerDetailReview({Key? key}) : super(key: key); | ||
final double textHeight = 10; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const ShimmerContainer( | ||
height: 200, | ||
), | ||
const SizedBox( | ||
height: 20, | ||
), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 10), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row( | ||
children: [ | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(50), | ||
child: const ShimmerContainer( | ||
width: 40, | ||
height: 40, | ||
), | ||
), | ||
const SizedBox( | ||
width: 15, | ||
), | ||
const ShimmerContainer( | ||
width: 200, | ||
) | ||
], | ||
), | ||
const SizedBox( | ||
height: 20, | ||
), | ||
const ShimmerContainer( | ||
width: 150, | ||
), | ||
const SizedBox( | ||
height: 20, | ||
), | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
ShimmerContainer( | ||
width: MediaQuery.of(context).size.width * .7, | ||
height: textHeight, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .8, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .6, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .9, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .9, | ||
), | ||
], | ||
), | ||
const SizedBox(height: 20), | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .8, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
width: MediaQuery.of(context).size.width * .6, | ||
height: textHeight, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .9, | ||
), | ||
const SizedBox( | ||
height: 5, | ||
), | ||
ShimmerContainer( | ||
height: textHeight, | ||
width: MediaQuery.of(context).size.width * .9, | ||
), | ||
], | ||
) | ||
], | ||
)) | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.