Fakultas Ilmu Komputer UI

Commit fa5bb785 authored by Fakhira Devina's avatar Fakhira Devina
Browse files

Merge branch 'dev-hira' into 'PBI-6-halaman_detail_fasilitas_publik'

Add comment place holder

See merge request !59
parents 887532e1 4624245b
Pipeline #44436 passed with stages
in 6 minutes and 39 seconds
<<<<<<< HEAD
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-20 12:56:31.966938","version":"1.15.17"}
=======
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+6\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-21 10:40:51.758556","version":"1.15.17"}
>>>>>>> staging
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}]}
\ No newline at end of file
......@@ -26,6 +26,7 @@ class KomentarBloc {
KomentarList komentarListResponse =
await _komentarRepository.fetchKomentar(namaLokasi);
allKomentarFromApi = List.from(komentarListResponse.allKomentar);
komentarListSink.add(NetworkModel.completed(komentarListResponse));
} catch (e) {
komentarListSink.add(NetworkModel.error(e.toString()));
......
import 'package:dio/dio.dart';
import 'package:mockito/mockito.dart';
class MockHttpClient extends Mock implements Dio {}
var dio;
getDioInstance(String env) {
dio = env == 'build' ? Dio() : MockHttpClient();
}
mockLokasiDependencies() {
when(dio.get(
any,
)).thenAnswer((_) async {
final expected = Future<Response<List<Map<String, dynamic>>>>.value(
Response<List<Map<String, dynamic>>>(statusCode: 200, data: [
{
"id": 1,
"name": "Soppeng",
"latitude": 100039203300.0,
"longitude": 100000000000.0,
"alamat": "Jalan Margonda Raya",
"no_telp": "081111111111",
"image": "test.jpg"
}
]));
return expected;
});
}
mockFasilitasDependencies(Map<String, dynamic> mockFasilitas) {
when(dio.get(
any,
)).thenAnswer((_) async {
final expected = Future<Response<Map<String, dynamic>>>.value(
Response<Map<String, dynamic>>(statusCode: 200, data: mockFasilitas));
return expected;
});
}
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/app.dart';
import 'flavor/flavor.dart';
import 'globalnetwork.dart';
void main() {
getDioInstance('build');
dio.options.receiveTimeout = 15000;
ApiFlavor.flavor = BuildFlavor.production.toString();
runApp(BisaGo());
......
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:ppl_disabilitas/globalnetwork.dart';
import 'package:ppl_disabilitas/network/CustomException.dart';
import 'package:http/http.dart' as http;
import 'dart:io';
class NetworkInterface {
//String key = KEY;
// POST request
Future<dynamic> post( {
String url, //url nya apa
dynamic bodyParams, //data apa yang mau dikasih
bool isLogin, //dia login apa ngga
}) async {
var responseJson;
final headersJson =
await _buildRequestHeader(isLogin); //butuh header apa ngga
try {
final response = await http.post(
final response = await dio.post(
"$url",
body: json.encode(bodyParams),
headers: headersJson,
data: json.encode(bodyParams),
//headers: headersJson,
);
responseJson = _response(response);
} on SocketException {
......@@ -34,11 +30,9 @@ class NetworkInterface {
bool isLogin,
}) async {
var responseJson;
final headersJson = await _buildRequestHeader(isLogin);
try {
final response = await http.get(
final response = await dio.get(
"$url",
headers: headersJson,
);
responseJson = _response(response);
} on SocketException {
......@@ -47,46 +41,19 @@ class NetworkInterface {
return responseJson;
}
// buildRequestHeader: untuk nentuin pake header apa aja berdasarkan login apa ngga
Future<Map<String, dynamic>> _buildRequestHeader(bool isLogin) async {
Map<String, String> headers = Map<String, String>();
headers.putIfAbsent("Content-Type", () => "application/json");
//if (isLogin) {
//List<dynamic> cookieFile = await CookiesInterface().getCookieFile(
// fileName:
// "userCookies"); //ngambil data dari yg udh disimpen di cookie
//print("cookieFile list --> ${cookieFile.toString()}");
//print("check key here >>> $key");
//setKey(cookieFile[2]);
//key = cookieFile[2];
//headers.putIfAbsent(
// "Authorization",
// () =>
// 'Token $key'); //ini kalau authorization nya ngga ada baru taro token nya
//headers.putIfAbsent("X-CSRFToken", () => cookieFile[0]); //csrf token
//headers.putIfAbsent(
// "Cookie",
// () =>
// "csrftoken=${cookieFile[0]};sessionid=${cookieFile[1]}"); //cookie file
//print("headers --> ${headers}");
//}
return headers;
}
dynamic _response(http.Response response) {
dynamic _response(Response response) {
switch (response.statusCode) {
case 200:
final responseJson = json.decode(response.body.toString());
return responseJson;
return response.data;
case 201:
var responseJson = json.decode(response.body.toString());
return responseJson;
return response.data;
case 400:
throw BadRequestException(response.body.toString());
throw BadRequestException(response.data.toString());
case 401:
case 403:
throw UnauthorisedException(response.body.toString());
throw UnauthorisedException(response.data.toString());
case 500:
default:
......
......@@ -47,7 +47,6 @@ class _FasilitasState extends State<Fasilitas> {
void initState() {
allKomentarFromApi = [];
_bloc = KomentarBloc(widget.nama);
komentarStream = _bloc.komentarListStream;
super.initState();
}
......@@ -83,6 +82,7 @@ class _FasilitasState extends State<Fasilitas> {
children: <Widget>[
Icon(Icons.place, color: Colors.black, size: 20),
Flexible(
key: Key('Alamat'),
child: Text(
widget.alamat,
softWrap: true,
......@@ -194,7 +194,7 @@ class _FasilitasState extends State<Fasilitas> {
),
),
StreamBuilder(
stream: komentarStream,
stream: _bloc.komentarListStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
......@@ -297,6 +297,8 @@ class _FasilitasState extends State<Fasilitas> {
child: ListView(
children: <Widget>[
InkWell(
key: Key('Urutan'),
child: Container(
decoration: BoxDecoration(
color: greenPale,
......@@ -327,6 +329,7 @@ class _FasilitasState extends State<Fasilitas> {
)),
),
InkWell(
key: Key('Jenis Fasilitas'),
child: Container(
decoration: BoxDecoration(
color: greenPale,
......@@ -376,6 +379,7 @@ class _FasilitasState extends State<Fasilitas> {
child: ListView(
children: <Widget>[
Row(
key: Key('Komentar Terbaru'),
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Theme(
......@@ -404,6 +408,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Komentar Terpopuler'),
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Theme(
......@@ -432,6 +437,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Container(
key: Key('Komentar dengan Rating Tertinggi'),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
......@@ -475,6 +481,7 @@ class _FasilitasState extends State<Fasilitas> {
child: ListView(
children: <Widget>[
Row(
key: Key('Kursi Roda'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -503,6 +510,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Lift'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -531,6 +539,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Toilet Disabilitas'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -559,6 +568,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Tempat Ibadah'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -587,6 +597,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Guiding Block'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -615,6 +626,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Bidang Miring (Ramp)'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -643,6 +655,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Teman Disabilitas'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -671,6 +684,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Juru Bahasa Isyarat'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -698,6 +712,7 @@ class _FasilitasState extends State<Fasilitas> {
),
],
),Row(
key: Key("Tongkat Disabilitas Netra"),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -726,6 +741,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key("Kursi Umum Disabilitas"),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -754,6 +770,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key("Parkir Umum"),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -782,6 +799,7 @@ class _FasilitasState extends State<Fasilitas> {
],
),
Row(
key: Key('Running Text'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -803,13 +821,14 @@ class _FasilitasState extends State<Fasilitas> {
),
),
Text(
"Tempat Ibadah",
"Running Text",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
key: Key('Parkir Disabilitas'),
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
......@@ -946,7 +965,7 @@ class _FasilitasState extends State<Fasilitas> {
await Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => AddInformasi(
nama: widget.nama,
)));
))).then((value) => _bloc.fetchKomentarList(widget.nama));
}
}
......
......@@ -68,7 +68,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
),
),
Text(
'${widget.komentar.creator}',
'${widget.komentar.creator}', style: TextStyle(fontSize: 18),
key: Key('creator-${widget.komentar.creator}'),
),
Text(
......@@ -88,7 +88,8 @@ class _DetailPostPageState extends State<DetailPostPage> {
borderRadius: regularBorderRadius,
boxShadow: regularShadow),
padding: EdgeInsets.all(smallSpace),
margin: EdgeInsets.symmetric(horizontal: smallSpace),
margin:
EdgeInsets.symmetric(horizontal: smallSpace),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
......@@ -167,7 +168,16 @@ class _DetailPostPageState extends State<DetailPostPage> {
)
],
),
)
),
Container(
key: Key('Komentar'),
padding: EdgeInsets.symmetric(vertical: regularSpace),
child: Text(
'Komentar',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w800),
)),
komentarPlaceHolder(
'test', widget.komentar.date_time, 'hard coded komentar')
],
),
),
......@@ -192,4 +202,39 @@ class _DetailPostPageState extends State<DetailPostPage> {
),
);
}
komentarPlaceHolder(String nama, DateTime date, String description) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CircleAvatar(
backgroundColor: greenPrimary,
child: Text('Test'),
),
Padding(
padding: const EdgeInsets.all(regularSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
nama,
style: TextStyle(fontSize: 18),
),
Text('${DateFormat('dd MMMM yyy hh:mm').format(date)}',
style: TextStyle(color: grayPrimary, fontSize: 16))
],
),
)
],
),
Container(
margin: EdgeInsets.only(bottom: regularSpace),
child: Text(description)),
Divider(color: grayPrimary,)
],
);
}
}
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/globalnetwork.dart';
import 'package:ppl_disabilitas/page/registrasi/registrasi.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
import 'package:ppl_disabilitas/utils/customTextField.dart';
......@@ -141,6 +143,9 @@ class LoginState extends State<Login> {
setState(() {
sharedPreferences.setString("token", tokenMap['token']);
sharedPreferences.setString("email", email);
dio.interceptors.add(InterceptorsWrapper(onRequest: (RequestOptions options) async {
options.headers['Authorization'] = 'Token ${tokenMap['token']}';
}));
Navigator.pushNamed(context, '/');
});
}
......
......@@ -215,7 +215,7 @@ class PencarianState extends State<Pencarian> {
telpon: places[index].no_telp,
url: places[index].image,
id: places[index].id,
)));
))).then((value) => _bloc.fetchRecentSearch());
},
child: Container(
decoration: BoxDecoration(
......@@ -249,6 +249,7 @@ class PencarianState extends State<Pencarian> {
color: Colors.black,
fontFamily: 'Muli',
),
overflow: TextOverflow.ellipsis,
),
Text(
places[index].alamat,
......
......@@ -5,14 +5,11 @@ class KomentarRepository {
Future<KomentarList> fetchKomentar(String namaLokasi) async {
String nama = namaLokasi.replaceAll(" ", "%20");
String url = "http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/" + nama;
print("in Repo");
print(url);
String url = "https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/" + nama;
final response = await _network.get(
url: url,
isLogin: false);
final data = response.values.toList();
print(data);
final data = response.values.toList().reversed.toList();
return KomentarList(
data.map<KomentarModel>((komentar) => KomentarModel.fromJson(komentar)).toList());
}
......
......@@ -10,8 +10,9 @@ class LokasiRepository {
Future<LokasiListResponse> fetchLokasi() async {
final response = await _network.get(
url:
'http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list/',
'https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list/',
isLogin: false);
return LokasiListResponse(
response.map<Lokasi>((lokasi) => Lokasi.fromJson(lokasi)).toList());
}
......
......@@ -35,6 +35,7 @@ dependencies:
smooth_star_rating: ^1.0.4+2
image_picker: ^0.6.5
font_awesome_flutter: ^8.8.1
dio: ^3.0.9
dev_dependencies:
flutter_test:
......
......@@ -36,6 +36,7 @@ void main() {
expect(find.byKey(Key('like')), findsOneWidget);
expect(find.byKey(Key('dislike')), findsOneWidget);
expect(find.byKey(Key('rating')), findsOneWidget);
expect(find.byKey(Key('Komentar')), findsOneWidget);
});
testWidgets('Detail post negative test', (WidgetTester tester) async {
......@@ -43,6 +44,7 @@ void main() {
await tester.pumpWidget(buildTestableWidget(detailPostPage));
expect(find.byKey(Key('appbar-text')), findsNothing);
expect(find.byKey(Key('creator')), findsNothing);
expect(find.byKey(Key('komentar')), findsNothing);
});
test('Should decrypt tag code', () {
......
......@@ -5,18 +5,39 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/globalnetwork.dart';
import 'package:ppl_disabilitas/page/filter_fasilitas/fasilitas.dart';
void main() {
final mockFasilitas = {
"2": {
"id": 2,
"nama_lokasi": "Margo City",
"deskripsi":
"Ada toilet khusus disabilitas terletak di lantai 2 dekat kintan, kondisinya bagus dan bersih layak pakai.\r\n\r\nAda kursi roda juga di customer service lantai dasar, saya tidak ingat jumlahnya ada berapa, tapi ada lumayan banyak.",
"creator": "",
"date_time": "2020-04-12T14:33:54.442Z",
"like": 20,
"dislike": 1,
"rating": 3,
"tag": ["KR", "TD"],
"image": "static/img/2669211407.jpg",
"is_verified": false
}
};
Widget buildTestableWidget(Widget widget) {
// https://docs.flutter.io/flutter/widgets/MediaQuery-class.html
return MediaQuery(data: MediaQueryData(), child: MaterialApp(home: widget));
}
setUp(() {
getDioInstance('test');
mockFasilitasDependencies(mockFasilitas);
});
testWidgets('find inside filter page', (WidgetTester tester) async {
// Provide the childWidget to the Container.
await tester.pumpWidget(buildTestableWidget(Fasilitas(
......@@ -28,18 +49,27 @@ void main() {
await tester.tap(find.byKey(Key('FilterButton')));
await tester.pump(Duration(seconds: 1));
// inside filter
expect(find.byType(Container), findsNWidgets(24));
expect(find.byType(Row), findsNWidgets(16));
expect(find.byType(Column), findsNWidgets(4));
expect(find.byType(Text), findsNWidgets(20));
expect(find.byType(Flex), findsNothing);
expect(find.text('jns fasilitas'), findsNothing);
expect(find.text('urutn'), findsNothing);
expect(find.text('hps smw'), findsNothing);
expect(find.byKey(Key('Urutan')), findsOneWidget);
expect(find.byKey(Key('Jenis Fasilitas')), findsOneWidget);
expect(find.byKey(Key('Komentar Terbaru')), findsOneWidget);
expect(find.byKey(Key('Komentar Terpopuler')), findsOneWidget);
expect(find.byKey(Key('Komentar dengan Rating Tertinggi')), findsOneWidget);
expect(find.byKey(Key('Kursi Roda')), findsOneWidget);
expect(find.byKey(Key('Lift')), findsOneWidget);
expect(find.byKey(Key('Toilet Disabilitas')), findsOneWidget);
expect(find.byKey(Key('Tempat Ibadah')), findsOneWidget);
await tester.drag(find.byKey(Key('Tempat Ibadah')), Offset(0,-200));
await tester.pump();
// expect(find.byKey(Key('Guiding Block')), findsOneWidget);
//expect(find.byKey(Key('Bidang Miring (Ramp)')), findsOneWidget);
//expect(find.byKey(Key('Juru Bahasa Isyarat')), findsOneWidget);
//expect(find.byKey(Key('Tongkat Disabilitas Netra')), findsOneWidget);
//expect(find.byKey(Key('Kursi Umum Disabilitas')), findsOneWidget);
//expect(find.byKey(Key('Parkir Umum')), findsOneWidget);
//expect(find.byKey(Key('Runing Text')), findsOneWidget);
//expect(find.byKey(Key('Parkir Disabilitas')), findsOneWidget);
// filter
expect(find.byType(Scaffold), findsOneWidget);
expect(find.byType(Icon), findsNWidgets(5));
await tester.tap(find.byKey(Key('Tambah Informasi')));
await tester.tap(find.byKey(Key('Alamat')));
await tester.pump();
});
......@@ -51,17 +81,14 @@ void main() {
telpon: '9217424',
url: 'afalklksafn',
)));
// Search for the childWidget in the tree and verify it exists.
expect(find.byType(Scaffold), findsOneWidget);