Fakultas Ilmu Komputer UI

Commit a7bbfff6 authored by Muhammad Ariq Basyar's avatar Muhammad Ariq Basyar
Browse files

Merge branch 'PBI-11-info-fasilitas-kegiatan-share' into dev-bugfix

parents be04391b a189ffc8
......@@ -5,6 +5,7 @@ import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/filter_fasilitas/fasilitas.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
......@@ -67,14 +68,11 @@ class _DetailPostPageState extends State<DetailPostPage> {
onTap: () async {
final link = await DynamicLinksServiceRepository()
.createDynamicLinkForFasilitas(
widget.komentar.id.toString(),
widget.komentar.id,
widget.lokasi.placeId,
);
await Share.share(
'Tersedia ${fasilitas[widget.komentar.tag]} di ${widget.lokasi.name}, Oleh: ${widget.komentar.creator}\n\n'
'Dapatkan info fasilitas ramah disabilitas selengkapnya dari aplikasi BisaGo!\n'
'$link\n',
);
await Share.share(ShareUtils.getFormattedMessage(
widget.komentar, widget.lokasi, link));
},
child: const Padding(
padding: EdgeInsets.all(doubleSpace),
......
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
abstract class BaseDynamicLinksServiceRepository {
Future<String> createDynamicLinkForFasilitas(
String fasilitasId, String placeId);
Future<String> createDynamicLinkForKegiatan(String id, String placeId);
Future<String> createDynamicLinkForFasilitas(int id, String placeId);
Future<String> createDynamicLinkForKegiatan(int id, String placeId);
Future<String> createDynamicLink(int id, String placeId, String type);
}
class DynamicLinksServiceRepository
implements BaseDynamicLinksServiceRepository {
@override
Future<String> createDynamicLinkForFasilitas(
String fasilitasId, String placeId) async {
Future<String> createDynamicLink(
int id, String placeId, String type) async {
var uriPrefix = 'https://bisago.page.link/';
final parameters = DynamicLinkParameters(
uriPrefix: uriPrefix,
link: Uri.parse(
'https://bisago.page.link/link?id=$fasilitasId&place_id=$placeId&type=fasilitas',
'https://bisago.page.link/link?id=$id&place_id=$placeId&type=$type',
),
androidParameters: AndroidParameters(
packageName: 'com.ppl.bisaGo',
......@@ -28,24 +27,15 @@ class DynamicLinksServiceRepository
final shortUrl = shortDynamicLink.shortUrl;
return shortUrl.toString();
}
@override
Future<String> createDynamicLinkForFasilitas(
int id, String placeId) async {
return createDynamicLink(id, placeId, 'fasilitas');
}
@override
Future<String> createDynamicLinkForKegiatan(
String fasilitasId, String placeId) async {
var uriPrefix = 'https://bisago.page.link/';
final parameters = DynamicLinkParameters(
uriPrefix: uriPrefix,
link: Uri.parse(
'https://bisago.page.link/link?id=$fasilitasId&place_id=$placeId&type=kegiatan',
),
androidParameters: AndroidParameters(
packageName: 'com.ppl.bisaGo',
),
);
final shortDynamicLink = await parameters.buildShortLink();
final shortUrl = shortDynamicLink.shortUrl;
return shortUrl.toString();
int id, String placeId) async {
return createDynamicLink(id, placeId, 'kegiatan');
}
}
import 'package:bisaGo/config/strings.dart';
import 'package:bisaGo/model/komentar.dart';
import 'package:bisaGo/model/lokasi.dart';
class ShareUtils {
static String getFormattedMessage(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();
}
}
......@@ -9,12 +9,12 @@ class MockDynamicLinksServiceRepository extends Fake
implements DynamicLinksServiceRepository {
@override
Future<String> createDynamicLinkForFasilitas(
String fasilitasId, String placeId) {
int id, String placeId) {
return Future.value(_mockLink);
}
@override
Future<String> createDynamicLinkForKegiatan(String id, String placeId) {
Future<String> createDynamicLinkForKegiatan(int id, String placeId) {
return Future.value(_mockLink);
}
}
......@@ -28,7 +28,7 @@ void main() {
testWidgets('Generate deep link for Fasilitas Test -- Positive',
(WidgetTester tester) async {
final generatedUrl = await MockDynamicLinksServiceRepository()
.createDynamicLinkForFasilitas('11', '22');
.createDynamicLinkForFasilitas(11, '22');
expect(generatedUrl, _mockLink);
});
......
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