Fakultas Ilmu Komputer UI

Commit 746b794c authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

[RED] Solve conflicts

parents e9bff404 0b055fa8
......@@ -6,4 +6,9 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
......@@ -8,7 +8,13 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:requestLegacyExternalStorage="true"
android:name="io.flutter.app.FlutterApplication"
android:label="bisaGo"
android:icon="@mipmap/launcher_icon">
......
......@@ -6,4 +6,9 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
3.5.1:
- Pengguna dapat mengubah informasi kegiatan yang sudah ada
3.5.0:
- Pengguna dapat mengganti foto profil
......
......@@ -36,14 +36,38 @@ class KegiatanBloc {
}
Future<dynamic> addNewKegiatan(
Map<String, dynamic> newKegiatanData, String placeId) async {
Map<String, dynamic> newKegiatanData) async {
try {
return await _kegiatanRepository.createKegiatan(newKegiatanData, placeId);
return await _kegiatanRepository.createKegiatan(newKegiatanData);
} catch (e) {
return Response('Failed to register komentar', 400);
}
}
Future<dynamic> updateKegiatan(
Map<String, dynamic> newKegiatanData,
String placeId,
int id
) async {
try {
return await _kegiatanRepository.updateKegiatan(
newKegiatanData, placeId, id);
} catch (e) {
return {'response': 'FAILED'};
}
}
Future<KegiatanModel> fetchDetailKegiatan(String placeId, int kegiatanId) async {
try {
return await _kegiatanRepository.fetchDetailKegiatan(
placeId,
kegiatanId
);
} catch (e) {
return KegiatanModel();
}
}
void resetKegiatanList() {
kegiatanListSink
.add(NetworkModel.completed(KegiatanList(allKegiatanFromApi)));
......
import 'dart:async';
import 'package:bisaGo/model/new_user.dart';
import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/repository/user_repository.dart';
import 'package:get_it/get_it.dart';
import 'package:http/http.dart';
class NewUserBloc {
UserRepository _userRepository;
StreamController _userController;
NewUserBloc() {
_userController = StreamController<NetworkModel<String>>();
_userRepository = GetIt.instance.get<BaseUserRepository>();
}
Future<bool> registerNewUser(NewUser newUser) async {
try {
await _userRepository.createUser(newUser);
return true;
} catch (_) {
return false;
}
}
Future<bool> updateUser(NewUser newUser) async {
try {
await _userRepository.updateUser(newUser);
return true;
} catch (_) {
return false;
}
}
Future<Response> updateUserPFP(Map<String, dynamic> newUserData) async {
try {
await _userRepository.updateUserProfile(newUserData);
return Response('Success', 200);
} catch (_) {
return Response('Failed to update user', 400);
}
}
void dispose() {
_userController?.close();
}
}
......@@ -4,49 +4,55 @@ import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/repository/user_repository.dart';
import 'package:bisaGo/model/user.dart';
import 'package:get_it/get_it.dart';
import 'package:http/http.dart';
class UserBloc {
UserRepository _userRepository;
StreamController _userController;
List<UserModel> userFromApi;
String email;
StreamSink<NetworkModel<User>> get userSink => _userController.sink;
Stream<NetworkModel<User>> get userStream => _userController.stream;
StreamSink<NetworkModel<DetailUserModel>> get userSink =>
_userController.sink;
UserBloc(String email) {
_userController = StreamController<NetworkModel<User>>();
Stream<NetworkModel<DetailUserModel>> get userStream =>
_userController.stream;
UserBloc({this.email}) {
_userController = StreamController<NetworkModel<DetailUserModel>>();
_userRepository = GetIt.instance.get<BaseUserRepository>();
fetchUserDetail(email);
}
Future<void> fetchUserDetail(String email) async {
Future<void> fetchUserDetail() async {
userSink.add(NetworkModel.loading('Getting user'));
final response = await getUserDetail(email);
if (response is DetailUserModel) {
userSink.add(NetworkModel.completed(response));
} else {
userSink.add(NetworkModel.error('Gagal untuk mendapatkan profile'));
}
}
Future<dynamic> getUserDetail(String email) async {
try {
final userResponse = await _userRepository.fetchUserDetail(email);
userFromApi = List.from(userResponse.user);
userSink.add(NetworkModel.completed(userResponse));
return await _userRepository.fetchUserDetail(email);
} catch (e) {
if (!_userController.isClosed) {
userSink.add(NetworkModel.error(e.toString()));
}
return e;
}
}
Future<UserModel> fetchUser(String email) async {
Future<DetailUserModel> updateUser(UpdateUserModel updateUser) async {
try {
await fetchUserDetail(email);
return userFromApi.first;
} catch (e) {
return await _userRepository.updateUser(updateUser, email);
} catch (_) {
return null;
}
}
Future<Response> updateUserProfile(Map<String, dynamic> newUserData) async {
Future<bool> registerNewUser(RegisterUserModel registerUserModel) async {
try {
return await _userRepository.updateUserProfile(newUserData);
} catch (e) {
return Response('Failed to update user', 400);
await _userRepository.registerUser(registerUserModel);
return true;
} catch (_) {
return false;
}
}
......
......@@ -5,17 +5,24 @@ class BisaGoAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final List<Widget> actions;
final Widget leading;
final backgroundColor;
const BisaGoAppBar(
{this.title = 'bisaGo', this.actions = const [], this.leading, Key key})
{this.title = 'bisaGo',
this.actions = const [],
this.backgroundColor = greenPrimary,
this.leading,
Key key})
: super(key: key);
@override
final Size preferredSize = const Size.fromHeight(55);
@override
Widget build(BuildContext context) {
return AppBar(
elevation: 15,
centerTitle: true,
backgroundColor: greenPrimary,
backgroundColor: backgroundColor,
automaticallyImplyLeading: leading == null,
leading: leading,
title: Row(
......
import 'dart:convert';
import 'package:bisaGo/page/informasi/list_sekolah.dart';
import 'package:bisaGo/page/profile/profile.dart';
import 'package:bisaGo/page/tentang_disabilitas/tentang_disabilitas.dart';
......@@ -65,7 +67,7 @@ class BisaGoDrawer extends StatelessWidget {
),
Container(
decoration:
BoxDecoration(border: Border(top: BorderSide(color: Colors.white))),
BoxDecoration(border: Border(top: BorderSide(color: Colors.white))),
),
];
menus.forEach((element) => drawerItem.add(element));
......@@ -168,7 +170,8 @@ class BisaGoDrawer extends StatelessWidget {
if (sharedPreferences.getString('token') == null) {
return 'Selamat datang ke BisaGo!';
} else {
return sharedPreferences.getString('email');
final userJson = jsonDecode(sharedPreferences.getString('user'));
return userJson['email'];
}
}
......
......@@ -2,6 +2,6 @@ import 'package:intl/intl.dart';
class CustomSerializer {
static DateTime stringToDateTime(String date) {
return DateFormat('dd-MM-yyyy hh:mm').parse(date);
return DateFormat('yyyy-MM-dd HH:mm').parse(date);
}
}
......@@ -99,6 +99,12 @@ const fasilitas = {
'TB': 'Tempat Parkir Biasa',
};
const zonaWaktu = [
'WIB',
'WITA',
'WIT',
];
String getTag(String tag) {
return tags[tag];
}
......@@ -13,34 +13,45 @@ class KegiatanList {
class KegiatanModel {
final int id;
@JsonKey(name: 'place_id')
final String placeId;
final String creator;
@JsonKey(name: 'creator_email')
final String creatorEmail;
String placeId;
String creator;
@JsonKey(name: 'nama_kegiatan')
final String namaKegiatan;
final String penyelenggara;
final String narahubung;
final String deskripsi;
String namaKegiatan;
@JsonKey(name: 'creator_email')
String creatorEmail;
String penyelenggara;
String deskripsi;
@JsonKey(name: 'nama_kontak')
String namaKontak;
@JsonKey(name: 'nomor_kontak')
String nomorKontak;
String links;
@JsonKey(name: 'time_start', fromJson: CustomSerializer.stringToDateTime)
final DateTime timeStart;
DateTime timeStart;
@JsonKey(name: 'time_end', fromJson: CustomSerializer.stringToDateTime)
final DateTime timeEnd;
List<String> image;
DateTime timeEnd;
@JsonKey(name: 'zona_waktu')
String zonaWaktu;
List<String> images;
KegiatanModel({
this.id,
this.placeId,
this.creator,
this.namaKegiatan,
this.penyelenggara,
this.narahubung,
this.deskripsi,
this.timeStart,
this.timeEnd,
this.image,
this.creatorEmail,
});
KegiatanModel(
{
this.id,
this.placeId,
this.creator,
this.namaKegiatan,
this.creatorEmail,
this.penyelenggara,
this.deskripsi,
this.namaKontak,
this.nomorKontak,
this.links,
this.timeStart,
this.timeEnd,
this.zonaWaktu,
this.images,
}
);
factory KegiatanModel.fromJson(Map<String, dynamic> json) =>
_$KegiatanModelFromJson(json);
......
......@@ -27,13 +27,16 @@ KegiatanModel _$KegiatanModelFromJson(Map<String, dynamic> json) {
placeId: json['place_id'] as String,
creator: json['creator'] as String,
namaKegiatan: json['nama_kegiatan'] as String,
creatorEmail: json['creator_email'] as String,
penyelenggara: json['penyelenggara'] as String,
narahubung: json['narahubung'] as String,
deskripsi: json['deskripsi'] as String,
namaKontak: json['nama_kontak'] as String,
nomorKontak: json['nomor_kontak'] as String,
links: json['links'] as String,
timeStart: CustomSerializer.stringToDateTime(json['time_start'] as String),
timeEnd: CustomSerializer.stringToDateTime(json['time_end'] as String),
image: (json['image'] as List)?.map((e) => e as String)?.toList(),
creatorEmail: json['creator_email'] as String,
zonaWaktu: json['zona_waktu'] as String,
images: (json['images'] as List)?.map((e) => e as String)?.toList(),
);
}
......@@ -42,12 +45,15 @@ Map<String, dynamic> _$KegiatanModelToJson(KegiatanModel instance) =>
'id': instance.id,
'place_id': instance.placeId,
'creator': instance.creator,
'creator_email': instance.creatorEmail,
'nama_kegiatan': instance.namaKegiatan,
'creator_email': instance.creatorEmail,
'penyelenggara': instance.penyelenggara,
'narahubung': instance.narahubung,
'deskripsi': instance.deskripsi,
'nama_kontak': instance.namaKontak,
'nomor_kontak': instance.nomorKontak,
'links': instance.links,
'time_start': instance.timeStart?.toIso8601String(),
'time_end': instance.timeEnd?.toIso8601String(),
'image': instance.image,
'zona_waktu': instance.zonaWaktu,
'images': instance.images,
};
import 'package:intl/intl.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:bisaGo/config/custom_serializer.dart';
part 'komentar.g.dart';
......@@ -16,7 +16,7 @@ class KomentarModel {
final String namaLokasi;
final String deskripsi;
final String creator;
@JsonKey(name: 'date_time', fromJson: CustomSerializer.stringToDateTime)
@JsonKey(name: 'date_time', fromJson: _stringToDateTime)
final DateTime dateTime;
final String tag;
final List<String> disabilitas;
......@@ -48,3 +48,7 @@ class KomentarModel {
Map<String, dynamic> toJson() => _$KomentarModelToJson(this);
}
DateTime _stringToDateTime(String date) {
return DateFormat('dd-MM-yyyy hh:mm').parse(date);
}
......@@ -27,7 +27,7 @@ KomentarModel _$KomentarModelFromJson(Map<String, dynamic> json) {
namaLokasi: json['nama_lokasi'] as String,
deskripsi: json['deskripsi'] as String,
creator: json['creator'] as String,
dateTime: CustomSerializer.stringToDateTime(json['date_time'] as String),
dateTime: _stringToDateTime(json['date_time'] as String),
tag: json['tag'] as String,
disabilitas:
(json['disabilitas'] as List)?.map((e) => e as String)?.toList(),
......
import 'package:intl/intl.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:bisaGo/config/custom_serializer.dart';
part 'komentar_posting.g.dart';
......@@ -16,7 +16,9 @@ class KomentarPostingModel {
final String creator;
@JsonKey(name: 'creator_email')
final String creatorEmail;
@JsonKey(fromJson: CustomSerializer.stringToDateTime)
@JsonKey(name: 'creator_picture')
final String creatorPicture;
@JsonKey(fromJson: _stringToDateTime)
final DateTime created;
KomentarPostingModel({
......@@ -24,6 +26,7 @@ class KomentarPostingModel {
this.deskripsi,
this.creator,
this.creatorEmail,
this.creatorPicture,
this.created,
});
......@@ -32,3 +35,7 @@ class KomentarPostingModel {
Map<String, dynamic> toJson() => _$KomentarPostingModelToJson(this);
}
DateTime _stringToDateTime(String date) {
return DateFormat('dd-MM-yyyy hh:mm').parse(date);
}
......@@ -28,7 +28,8 @@ KomentarPostingModel _$KomentarPostingModelFromJson(Map<String, dynamic> json) {
deskripsi: json['deskripsi'] as String,
creator: json['creator'] as String,
creatorEmail: json['creator_email'] as String,
created: CustomSerializer.stringToDateTime(json['created'] as String),
creatorPicture: json['creator_picture'] as String,
created: _stringToDateTime(json['created'] as String),
);
}
......@@ -39,5 +40,6 @@ Map<String, dynamic> _$KomentarPostingModelToJson(
'deskripsi': instance.deskripsi,
'creator': instance.creator,
'creator_email': instance.creatorEmail,
'creator_picture': instance.creatorPicture,
'created': instance.created?.toIso8601String(),
};
import 'package:intl/intl.dart';
import 'package:bisaGo/config/custom_serializer.dart';
import 'package:json_annotation/json_annotation.dart';
part 'komentar_posting_kegiatan.g.dart';
......@@ -15,8 +15,10 @@ class KomentarPostingKegiatanModel {
final String creator;
@JsonKey(name: 'creator_email')
final String creatorEmail;
@JsonKey(name: 'creator_picture')
final String creatorPicture;
final String deskripsi;
@JsonKey(name: 'created', fromJson: _stringToDateTime)
@JsonKey(name: 'created', fromJson: CustomSerializer.stringToDateTime)
final DateTime created;
KomentarPostingKegiatanModel({
......@@ -25,6 +27,7 @@ class KomentarPostingKegiatanModel {
this.deskripsi,
this.created,
this.creatorEmail,
this.creatorPicture,
});
factory KomentarPostingKegiatanModel.fromJson(Map<String, dynamic> json) =>
......@@ -32,7 +35,3 @@ class KomentarPostingKegiatanModel {
Map<String, dynamic> toJson() => _$KomentarPostingKegiatanModelToJson(this);
}
DateTime _stringToDateTime(String date) {
return DateFormat('yyy-MM-dd hh:mm').parse(date);
}
......@@ -29,8 +29,9 @@ KomentarPostingKegiatanModel _$KomentarPostingKegiatanModelFromJson(
id: json['id'] as int,
creator: json['creator'] as String,
deskripsi: json['deskripsi'] as String,
created: _stringToDateTime(json['created'] as String),
created: CustomSerializer.stringToDateTime(json['created'] as String),
creatorEmail: json['creator_email'] as String,
creatorPicture: json['creator_picture'] as String,
);
}
......@@ -40,6 +41,7 @@ Map<String, dynamic> _$KomentarPostingKegiatanModelToJson(
'id': instance.id,
'creator': instance.creator,
'creator_email': instance.creatorEmail,
'creator_picture': instance.creatorPicture,
'deskripsi': instance.deskripsi,
'created': instance.created?.toIso8601String(),
};
import 'package:json_annotation/json_annotation.dart';
part 'new_user.g.dart';
@JsonSerializable()
class NewUser {
String name;
String password;
String email;
@JsonKey(name: 'tanggal_lahir')
String tanggalLahir;
@JsonKey(name: 'jenis_kelamin')
String jenisKelamin;
String disabilitas;
String pekerjaan;
String alamat;
@JsonKey(name: 'phone_number')
String phoneNumber;
String foto;
bool seen;
@JsonKey(name: 'organisasi_komunitas')
String organisasiKomunitas;
NewUser({
this.name,
this.password,
this.email,
this.tanggalLahir,
this.jenisKelamin,
this.disabilitas,
this.pekerjaan,
this.alamat,
this.phoneNumber,
this.foto,
this.seen,
this.organisasiKomunitas,
});
factory NewUser.fromJson(Map<String, dynamic> json) =>
_$NewUserFromJson(json);
Map<String, dynamic> toJson() => _$NewUserToJson(this);
}
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