Fakultas Ilmu Komputer UI

Verified Commit 5d6063d8 authored by Muhammad Ariq Basyar's avatar Muhammad Ariq Basyar
Browse files

[GREEN] share for kegiatan

parent a7bbfff6
Pipeline #77398 passed with stages
in 17 minutes and 58 seconds
......@@ -3,6 +3,8 @@ import 'package:bisaGo/model/komentar.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/bloc/kegiatan_terdekat_bloc.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart';
import 'package:bisaGo/repository/kegiatan_repository.dart';
import 'package:bisaGo/utils/custom_kegiatan_terdekat_button.dart';
import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post.dart';
......@@ -319,7 +321,8 @@ class DashboardState extends State<Dashboard> {
'name',
],
);
return details.result.name;
final result = details.result;
return result == null ? 'INVALID' : result.name;
}
void _navigateToDetailFasilitasPage(
......@@ -352,6 +355,36 @@ class DashboardState extends State<Dashboard> {
await Navigator.of(context).push(fasilitasRoute);
}
void _navigateToDetailKegiatanPage(
BuildContext context, String placeId, int fasilitasId) async {
final fetches = await Future.wait([
KegiatanRepository().fetchDetailKegiatan(placeId, fasilitasId),
getLokasiName(placeId),
]);
final KegiatanModel kegiatan = fetches[0];
final String namaLokasi = fetches[1] ?? 'INVALID';
final lokasi = Lokasi()
..placeId = placeId
..name = namaLokasi;
final fasilitasRoute = MaterialPageRoute(
builder: (BuildContext context) => DetailPostKegiatanPage(
lokasi: lokasi,
kegiatan: KegiatanModel(
id: kegiatan.id,
placeId: lokasi.placeId,
creator: kegiatan.creator,
namaKegiatan: kegiatan.namaKegiatan,
penyelenggara: kegiatan.penyelenggara,
narahubung: kegiatan.narahubung,
deskripsi: kegiatan.deskripsi,
timeStart: kegiatan.timeStart,
timeEnd: kegiatan.timeEnd,
image: kegiatan.image,
),
));
await Navigator.of(context).push(fasilitasRoute);
}
void initDynamicLinks() async {
final data = await FirebaseDynamicLinks.instance.getInitialLink();
......@@ -376,7 +409,7 @@ class DashboardState extends State<Dashboard> {
if (type == 'fasilitas') {
_navigateToDetailFasilitasPage(context, placeId, id);
} else if (type == 'kegiatan') {
// TODO(:ariqbasyar) navigate kegiatan
_navigateToDetailKegiatanPage(context, placeId, id);
}
}
}
......
......@@ -71,7 +71,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
widget.komentar.id,
widget.lokasi.placeId,
);
await Share.share(ShareUtils.getFormattedMessage(
await Share.share(ShareUtils.getFormattedMessageFasilitas(
widget.komentar, widget.lokasi, link));
},
child: const Padding(
......
......@@ -2,7 +2,8 @@ import 'dart:async';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart';
// import 'package:bisaGo/page/updateInformasi/update_informasi.dart';
import 'package:bisaGo/repository/dynamic_links_service_repository.dart';
import 'package:bisaGo/utils/share_utils.dart';
import 'package:bisaGo/utils/validator.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/cupertino.dart';
......@@ -58,13 +59,19 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
key: Key('appbar-text-${widget.kegiatan.placeId}'),
actions: <Widget>[
InkWell(
onTap: () => Share.share(
'Review kegiatan disabilitas di ${widget.lokasi.name}, '
'oleh: ${widget.kegiatan.creator}\n\"${widget.kegiatan.deskripsi}\"\n\nDapatkan info fasilitas ramah '
'disabilitas dari aplikasi bisaGo!\nDownload bisaGo '
'sekarang di: https://bit.ly/DownloadbisaGo'),
child: const Icon(Icons.share),
// ganti format share
onTap: () async {
final link = await DynamicLinksServiceRepository()
.createDynamicLinkForKegiatan(
widget.kegiatan.id,
widget.lokasi.placeId,
);
await Share.share(ShareUtils.getFormattedMessageKegiatan(
widget.kegiatan, widget.lokasi, link));
},
child: const Padding(
padding: EdgeInsets.all(doubleSpace),
child: Icon(Icons.share),
),
),
],
),
......
......@@ -7,6 +7,7 @@ abstract class BaseKegiatanRepository {
Future<List<String>> fetchImages(String placeId, int id);
Future<dynamic> createKegiatan(
Map<String, dynamic> newKegiatanData, String placeId);
Future<KegiatanModel> fetchDetailKegiatan(String placeId, int kegiatanId);
}
class KegiatanRepository implements BaseKegiatanRepository {
......@@ -48,11 +49,19 @@ class KegiatanRepository implements BaseKegiatanRepository {
Map<String, dynamic> newKegiatanData,
String placeId,
) async {
print(newKegiatanData);
final response = await _network.post(
url: '/informasi-fasilitas/lokasi/add-kegiatan/$placeId/',
bodyParams: newKegiatanData,
);
return response;
}
@override
Future<KegiatanModel> fetchDetailKegiatan(String placeId, int kegiatanId) async {
final url = '/informasi-fasilitas/lokasi/detail-kegiatan/$placeId/$kegiatanId/';
final response = await _network.get(url: url, isLogin: false);
var kegiatan = KegiatanModel.fromJson(response);
kegiatan.image = await fetchImages(kegiatan.placeId, kegiatan.id);
return kegiatan;
}
}
......@@ -12,7 +12,6 @@ class KegiatanTerdekatRepository implements BaseKegiatanTerdekatRepository {
final response = await _network.get(
url: '/informasi-fasilitas/lokasi/kegiatan-terdekat', isLogin: false);
var kegiatan = KegiatanModel.fromJson(response);
print(response);
kegiatan.image = await fetchFotoKegiatan(kegiatan.placeId, kegiatan.id);
return kegiatan;
}
......
import 'package:bisaGo/config/strings.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/komentar.dart';
import 'package:bisaGo/model/lokasi.dart';
class ShareUtils {
static String getFormattedMessage(KomentarModel komentar, Lokasi lokasi, String link) {
static String getFormattedMessageFasilitas(KomentarModel komentar, Lokasi lokasi, String link) {
return
'''
Tersedia ${fasilitas[komentar.tag]} di ${lokasi.name}, Oleh: ${komentar.creator}
Dapatkan info fasilitas ramah disabilitas selengkapnya dari aplikasi BisaGo!
$link
'''.trim();
}
static String getFormattedMessageKegiatan(KegiatanModel kegiatan, Lokasi lokasi, String link) {
return
'''
Terdapat ${kegiatan.namaKegiatan} di ${lokasi.name}, Oleh: ${kegiatan.creator}
Dapatkan info kegiatan ramah disabilitas selengkapnya dari aplikasi BisaGo!
$link
'''.trim();
}
}
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