Fakultas Ilmu Komputer UI

Commit b5a1c770 authored by Dzaky Noor Hasyim's avatar Dzaky Noor Hasyim
Browse files

[GREEN] Adding and modify dashboard kegiatan_terdekat button, routing still failed

parent 41ca4e37
Pipeline #76891 failed with stages
in 1 minute and 27 seconds
import 'package:bisaGo/bloc/lokasi_response_bloc.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/bloc/kegiatan_terdekat_bloc.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/utils/custom_kegiatan_terdekat_button.dart';
import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/utils/custom_dashboard_location_button.dart';
import 'package:bisaGo/utils/location_turn_on_dialog.dart';
......@@ -25,6 +28,7 @@ class DashboardState extends State<Dashboard> {
Set<Marker> markers = {};
LokasiResponseBloc bloc = LokasiResponseBloc();
KegiatanTerdekatBloc blocKegiatanTerdekat = KegiatanTerdekatBloc();
@override
void initState() {
......@@ -98,25 +102,42 @@ class DashboardState extends State<Dashboard> {
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: doubleSpace),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Kopdar Rutin, Senin 3 Mei 2021',
style:TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
),
),
Container(child:Text('more info>',
style:TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'Muli',
fontStyle: FontStyle.italic,
),))
]
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
......@@ -252,6 +273,12 @@ class DashboardState extends State<Dashboard> {
);
}
Widget _buildKegiatanTerdekatWidget(KegiatanModel kegiatanModel) {
return Container(
child: KegiatanTerdekatButton(kegiatan:kegiatanModel)
);
}
Widget _buildGoogleMap(BuildContext context) {
if (currentLocation == null) {
return const Center(
......
import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/model/kegiatan.dart';
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';
class KegiatanTerdekatButton extends StatefulWidget {
const KegiatanTerdekatButton({
this.key,
this.kegiatan,
this.onPressed,
}) : super(key: key);
final KegiatanModel kegiatan;
@override
final Key key;
final Function onPressed;
@override
_KegiatanTerdekatButtonState createState() => _KegiatanTerdekatButtonState();
}
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);
}
@override
Widget build(BuildContext context) {
return FlatButton(
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,
)
)
],
)
)
);
}
String getKegiatanStr(){
return widget.kegiatan.namaKegiatan;//+widget.kegiatan.timeStart;
}
}
\ 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