Fakultas Ilmu Komputer UI

Commit 4993d1cb authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[CHORES] Fix linter

parent 9f86f284
......@@ -16,7 +16,8 @@ class KegiatanTerdekatBloc {
KegiatanTerdekatBloc() {
_kegiatanTerdekatController = BehaviorSubject<NetworkModel>();
_kegiatanTerdekatRepository = GetIt.instance.get<BaseKegiatanTerdekatRepository>();
_kegiatanTerdekatRepository =
GetIt.instance.get<BaseKegiatanTerdekatRepository>();
fetchKegiatanTerdekat();
}
......@@ -24,10 +25,11 @@ class KegiatanTerdekatBloc {
kegiatanTerdekatSink.add(NetworkModel.loading('Loading Kegiatan'));
try {
final kegiatanTerdekatResponse =
await _kegiatanTerdekatRepository.fetchKegiatanTerdekatResponse();
kegiatanTerdekatSink.add(NetworkModel.completed(kegiatanTerdekatResponse));
await _kegiatanTerdekatRepository.fetchKegiatanTerdekatResponse();
kegiatanTerdekatSink
.add(NetworkModel.completed(kegiatanTerdekatResponse));
} catch (e) {
kegiatanTerdekatSink.add(NetworkModel.error(e.toString()));
}
}
}
\ No newline at end of file
}
......@@ -92,157 +92,150 @@ class DashboardState extends State<Dashboard> {
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 35),
child:_buildGoogleMap(context)),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: _buildGoogleMap(context)),
Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <
Widget>[
Container(
height: 40,
alignment: Alignment.center,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)
),
bottomLeft: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: doubleSpace),
child: StreamBuilder<NetworkModel>(
stream: blocKegiatanTerdekat.kegiatanTerdekatStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return Container(
child: const Center(
child: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
)
)
);
break;
case Status.completed:
final kegiatanTerdekat =
snapshot.data.data;
return _buildKegiatanTerdekatWidget(
kegiatanTerdekat);
break;
case Status.error:
return Container(
child: const Center(child:
Text('Tidak ada kegiatan dalam waktu dekat',
style: TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),));
break;
}
return Container();
}
return Container();
}
)
)
), // Container info kegiatan
Container(
height: 285,
alignment: Alignment.bottomCenter,
decoration: const BoxDecoration(
color: white,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
padding: const EdgeInsets.symmetric(
horizontal: doubleSpace, vertical: doubleSpace),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
key: const Key('Navigate to Pencarian'),
onTap: () => _navigateToPencarianPage(context),
child: Container(
key: const Key('Container Text Field'),
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: regularBorderRadius,
border: Border.all(color: greenPrimary),
boxShadow: regularShadow),
child: TextFormField(
enabled: false,
key: const Key('Text Field Mau Kemana'),
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.search,
color: greenPrimary,
size: 25,
),
border: InputBorder.none,
fillColor: Colors.white,
labelText: 'Tekan untuk mencari tempat',
labelStyle: TextStyle(
color: greenPrimary,
fontSize: 20,
fontFamily: 'Muli',
fontWeight: FontWeight.w700),
),
),
),
),
const SizedBox(height: doubleSpace),
const Text(
'Paling sering dicari',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
StreamBuilder<NetworkModel<LokasiListResponse>>(
stream: bloc.lokasiListStream,
padding:
const EdgeInsets.symmetric(horizontal: doubleSpace),
child: StreamBuilder<NetworkModel>(
stream: blocKegiatanTerdekat.kegiatanTerdekatStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return Container(
height: 130,
child: const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
),
),
);
child: const Center(
child: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
)));
break;
case Status.completed:
final places = snapshot.data.data.listLokasi;
return _buildLokasiWidget(places);
final kegiatanTerdekat = snapshot.data.data;
return _buildKegiatanTerdekatWidget(
kegiatanTerdekat);
break;
case Status.error:
return Container(
height: 130,
child: const Center(
child: Text('Gagal untuk mendapatkan tempat'),
),
);
child: const Center(
child: Text(
'Tidak ada kegiatan dalam waktu dekat',
style: TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
));
break;
}
return Container();
}
return Container();
}),
],
}))), // Container info kegiatan
Container(
height: 285,
alignment: Alignment.bottomCenter,
decoration: const BoxDecoration(
color: white,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
]
)
),
padding: const EdgeInsets.symmetric(
horizontal: doubleSpace, vertical: doubleSpace),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
key: const Key('Navigate to Pencarian'),
onTap: () => _navigateToPencarianPage(context),
child: Container(
key: const Key('Container Text Field'),
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: regularBorderRadius,
border: Border.all(color: greenPrimary),
boxShadow: regularShadow),
child: TextFormField(
enabled: false,
key: const Key('Text Field Mau Kemana'),
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.search,
color: greenPrimary,
size: 25,
),
border: InputBorder.none,
fillColor: Colors.white,
labelText: 'Tekan untuk mencari tempat',
labelStyle: TextStyle(
color: greenPrimary,
fontSize: 20,
fontFamily: 'Muli',
fontWeight: FontWeight.w700),
),
),
),
),
const SizedBox(height: doubleSpace),
const Text(
'Paling sering dicari',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
StreamBuilder<NetworkModel<LokasiListResponse>>(
stream: bloc.lokasiListStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return Container(
height: 130,
child: const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
),
),
);
break;
case Status.completed:
final places = snapshot.data.data.listLokasi;
return _buildLokasiWidget(places);
break;
case Status.error:
return Container(
height: 130,
child: const Center(
child: Text('Gagal untuk mendapatkan tempat'),
),
);
break;
}
return Container();
}
return Container();
}),
],
),
),
])
],
),
// floatingActionButton: FloatingActionButton.extended(
......@@ -281,9 +274,7 @@ class DashboardState extends State<Dashboard> {
}
Widget _buildKegiatanTerdekatWidget(KegiatanModel kegiatanModel) {
return Container(
child: KegiatanTerdekatButton(kegiatan:kegiatanModel)
);
return Container(child: KegiatanTerdekatButton(kegiatan: kegiatanModel));
}
Widget _buildGoogleMap(BuildContext context) {
......
This diff is collapsed.
......@@ -91,8 +91,6 @@ class LokasiRepository implements BaseLokasiRepository {
components: [Component(Component.country, 'id')],
);
print(_res.predictions.length);
final _placesDetails = await Future.wait(
_res.predictions
.map<Future<PlacesDetailsResponse>>(
......
......@@ -4,6 +4,8 @@ import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:google_maps_webservice/places.dart';
class KegiatanTerdekatButton extends StatefulWidget {
const KegiatanTerdekatButton({
......@@ -22,50 +24,59 @@ class KegiatanTerdekatButton extends StatefulWidget {
}
class _KegiatanTerdekatButtonState extends State<KegiatanTerdekatButton> {
void _navigateToDetailPostKegiatanPage(BuildContext context) {
var lokasi = null; //Lokasi.getDetailsByPlaceId(widget.kegiatan.placeId);
final route =
MaterialPageRoute(builder: (_) => DetailPostKegiatanPage(
kegiatan: widget.kegiatan,
lokasi: lokasi));
Navigator.of(context).push(route);
Future<String> _getLokasiName(String placeId) async {
final _places = GoogleMapsPlaces(apiKey: DotEnv().env['API_KEY']);
var details = await _places.getDetailsByPlaceId(
placeId,
fields: [
'name',
],
);
return details.result.name;
}
void _navigateToDetailPostKegiatanPage(BuildContext context) async {
var lokasi = Lokasi()
..name = await _getLokasiName(widget.kegiatan.placeId)
..placeId = widget.kegiatan.placeId;
final route = MaterialPageRoute(
builder: (_) =>
DetailPostKegiatanPage(kegiatan: widget.kegiatan, lokasi: lokasi));
await Navigator.of(context).push(route);
}
@override
Widget build(BuildContext context) {
return FlatButton(
padding: EdgeInsets.zero,
onPressed: () {
_navigateToDetailPostKegiatanPage(context);
},
return TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
onPressed: () {
_navigateToDetailPostKegiatanPage(context);
},
child: Container(
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.kegiatan.namaKegiatan,//+widget.kegiatan.deskripsi,
style: const TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
Text(
'more info>',
style:TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'Muli',
fontStyle: FontStyle.italic,
)
)
],
)
)
);
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.kegiatan.namaKegiatan, //+widget.kegiatan.deskripsi,
style: const TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
Text('more info>',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'Muli',
fontStyle: FontStyle.italic,
))
],
)));
}
String getKegiatanStr(){
return widget.kegiatan.namaKegiatan;//+widget.kegiatan.timeStart;
String getKegiatanStr() {
return widget.kegiatan.namaKegiatan; //+widget.kegiatan.timeStart;
}
}
\ No newline at end of file
}
import 'package:bisaGo/config/strings.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/dashboard/dashboard.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart';
import 'package:bisaGo/repository/kegiatan_repository.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:flutter/material.dart';
......@@ -31,11 +28,12 @@ class MockKegiatanTerdekat extends Fake implements KegiatanTerdekatRepository {
class MockLokasi extends Fake implements LokasiRepository {
final mockLokasi = {
'name': 'Margo City',
'alamat': 'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'Margo.jpg',
'no_telp': '02178870888',
'counter': 69,
'name': 'Margo City',
'alamat':
'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'Margo.jpg',
'no_telp': '02178870888',
'counter': 69,
};
@override
Future<LokasiListResponse> fetchLokasi() async {
......@@ -44,41 +42,39 @@ class MockLokasi extends Fake implements LokasiRepository {
}
void main() {
final mockLokasi = {
'name': 'Margo City',
'alamat': 'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'Margo.jpg',
'no_telp': '02178870888',
'counter': 69,
};
// final mockLokasi = {
// 'name': 'Margo City',
// 'alamat':
// 'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
// 'image': 'Margo.jpg',
// 'no_telp': '02178870888',
// 'counter': 69,
// };
final mockKegiatan = {
'id': 2,
'nama_lokasi': 'Margo City',
'creator': 'Putri Salsabila',
'nama_kegiatan': 'Kopdar Rutin',
'penyelenggara': 'DTB Indonesia',
'narahubung': 'Putsal 08123123123',
'deskripsi': 'lorem ipsum dolor sit amet',
'time_start': '12-12-2021 06:30:00',
'time_end': '12-12-2021 09:30:00'
};
// final mockKegiatan = {
// 'id': 2,
// 'nama_lokasi': 'Margo City',
// 'creator': 'Putri Salsabila',
// 'nama_kegiatan': 'Kopdar Rutin',
// 'penyelenggara': 'DTB Indonesia',
// 'narahubung': 'Putsal 08123123123',
// 'deskripsi': 'lorem ipsum dolor sit amet',
// 'time_start': '12-12-2021 06:30:00',
// 'time_end': '12-12-2021 09:30:00'
// };
setUpAll(() {
final _getIt = GetIt.instance;
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekat());
_getIt.registerLazySingleton<BaseLokasiRepository>(
() => MockLokasi());
() => MockKegiatanTerdekat());
_getIt.registerLazySingleton<BaseLokasiRepository>(() => MockLokasi());
});
testWidgets(
'Detail Post Kegiatan Page - Positive Test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Dashboard()
));
testWidgets('Detail Post Kegiatan Page - Positive Test',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: Dashboard()));
await tester.pump();
expect(find.byType(Dashboard), findsOneWidget);
expect(find.text('Kopdar Rutin'), findsOneWidget);
});
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment