Skip to content

Commit

Permalink
Finish TanyaBund Page (#8)
Browse files Browse the repository at this point in the history
* create models for Artikel and create get-post method

* refactor method get and post

* create myartikel.dart for artikel page

* create artikel_by_id.dart

* create floating action button for tambah artikel

* create form_tambah_artikel.dart for form tambah artikel page

* delete keyboard type in form tambah artikel

* Implement auth: done (#3)

* Init authentication page

* Add bottom navbar

* Implement login and signup UI

* Authentication: done

* edit _bacabund.dart

* add conditional for floating action button in myartikel.dart

* changed widget name into MyArtikel

* add BacaBundPage to routes_factory.dart, but still got an error

* fixed bug string got null

* fixed bug in models and method get artikel

* change button color into red

* fixed overflow in login page

* fixed overflow in signup page

* use the postArtikel method in form page

* change the login and signup url & changed models attribute variable names

* trash #1

* create new post method using request.post, but still got an error

* fixed bugs in post artikel

* fixed bugs in button simpan form artikel

* delete unnecessary comments

* add configuration for deployment

* use circular progress indicator while fetching artikel

* add state while fetching data

* Periksabund ui

* Create Home, Onboarding, and TanyaBund Page (#4)

* Feat: TanyaBund Post Question and Answer (#5)

* Create Home, Onboarding, and TanyaBund Page

* Feat: Implement Functionality to Add Question and Answer

* new branch

* Temporary commit

* get post

* Commit

* Add Functionality to Delete Question and Answer (#6)

* Create Home, Onboarding, and TanyaBund Page

* Feat: Implement Functionality to Add Question and Answer

* Add Functionality to Delete Question and Answer

* Fix: Conflict

* Finishing TanyaBund

* PeriksaBund Get, Post #1

* Pubspec commit

* change appbar color

* merge development

* delete codes for debugging

* Commit pubspec

* Change Api to Railway

* add if else for faskes

* railway

* scrollview

* PeriksaBund Delete Feature #1

* scrollview

* Implementing Logout

* Commit

Co-authored-by: iqbalpa <[email protected]>
Co-authored-by: shafanjw <[email protected]>
Co-authored-by: dionavarastika <[email protected]>
  • Loading branch information
4 people authored Dec 12, 2022
1 parent b1ab5ab commit 8070135
Show file tree
Hide file tree
Showing 78 changed files with 4,223 additions and 169 deletions.
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ linter:
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
require_trailing_commas: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
Binary file added assets/images/book_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/diary_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/question_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/snap_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/stetoskop_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/timbangan_homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added flutter_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 15 additions & 57 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:endterm_project/routes/routes_factory.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';

void main() {
runApp(const MyApp());
Expand All @@ -10,63 +12,19 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
onGenerateRoute: (settings) {
return MaterialPageRoute<void>(
settings: settings,
builder: (_) => getScreenByName(settings.name!),
);
},
theme: ThemeData(
primarySwatch: Colors.blue,
),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
return Provider(
create: (BuildContext context) {
CookieRequest request = CookieRequest();
return request;
},
child: MaterialApp(
title: 'Flutter Demo',
onGenerateRoute: (settings) {
return MaterialPageRoute<void>(
settings: settings,
builder: (_) => getScreenByName(settings.name!),
);
},
),
);
}
Expand Down
39 changes: 39 additions & 0 deletions lib/models/bacabund/artikel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'dart:convert';

List<Artikel> artikelFromJson(String str) => List<Artikel>.from(
json.decode(str).map((artikel) => Artikel.fromJson(artikel)));

String artikelToJson(List<Artikel> data) =>
json.encode(List<dynamic>.from(data.map((artikel) => artikel.toJson())));

class Artikel {
Artikel({
required this.id,
required this.judul,
required this.isi,
required this.author,
required this.tanggal,
});

int id;
String judul;
String isi;
String author;
String tanggal;

factory Artikel.fromJson(Map<String, dynamic> json) => Artikel(
id: json['pk'],
judul: json['fields']['judul'],
isi: json['fields']['isi'],
tanggal: json['fields']['tanggal'],
author: json['fields']['author'],
);

Map<String, dynamic> toJson() => {
'id': id,
'judul': judul,
'isi': isi,
'author': author,
'tanggal': tanggal,
};
}
41 changes: 41 additions & 0 deletions lib/models/catatbund/catat.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// To parse this JSON data, do
//
// final catat = catatFromJson(jsonString);

import 'dart:convert';

Catat catatFromJson(String str) => Catat.fromJson(json.decode(str));

String catatToJson(Catat data) => json.encode(data.toJson());

class Catat {
Catat({
required this.user,
required this.date,
required this.weight,
required this.height,
required this.bmi,
});

int user;
String date;
double weight;
double height;
double bmi;

factory Catat.fromJson(Map<String, dynamic> json) => Catat(
user: json["user"],
date: json["date"],
weight: json["weight"].toDouble(),
height: json["height"].toDouble(),
bmi: json["bmi"].toDouble(),
);

Map<String, dynamic> toJson() => {
"user": user,
"date": date,
"weight": weight,
"height": height,
"bmi": bmi,
};
}
44 changes: 44 additions & 0 deletions lib/models/periksabund/informasi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'dart:convert';

List<Note> informasiFromJson(String str) => List<Note>.from(
json.decode(str).map((informasi) => Note.fromJson(informasi)));

String informasiToJson(List<Note> data) =>
json.encode(List<dynamic>.from(data.map((informasi) => informasi.toJson())));

class Note {
Note({
required this.id,
required this.user,
required this.lokasi,
required this.tanggal,
required this.waktu,
required this.kapasitas_balita,
});

int id;
int user;
String lokasi;
String tanggal;
String waktu;
int kapasitas_balita;


factory Note.fromJson(Map<String, dynamic> json) => Note(
id: json['id'],
user: json['user_id'],
lokasi: json['lokasi'],
tanggal: json['tanggal'],
waktu: json['waktu'],
kapasitas_balita: json['kapasitas_balita'],
);

Map<String, dynamic> toJson() => {
'id':id,
'user': user,
'lokasi': lokasi,
'tanggal': tanggal,
'waktu': waktu,
'kapasitas_balita': kapasitas_balita,
};
}
77 changes: 77 additions & 0 deletions lib/models/tanyabund/answer_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'dart:convert';

List<AnswerModel> answerModelFromJson(String str) => List<AnswerModel>.from(json.decode(str).map((x) => AnswerModel.fromJson(x)));

String answerModelToJson(List<AnswerModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class AnswerModel {
AnswerModel({
required this.model,
required this.pk,
required this.user,
required this.text,
required this.date,
required this.questionPk,
required this.roleUser,
});

String model;
int pk;
String user;
String text;
DateTime date;
int questionPk;
String roleUser;

factory AnswerModel.fromJson(Map<String, dynamic> json) => AnswerModel(
model: json['model'],
pk: json['pk'],
user: List<String>.from(json['fields']['user'].map((x) => x)).first,
text: json['fields']['text'],
date: DateTime.parse(json['fields']['date']),
questionPk: json['fields']['question'],
roleUser: json['fields']['role_user'],
);

Map<String, dynamic> toJson() => {
'model': model,
'pk': pk,
'user': user,
'text': text,
'date': "${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
'question': questionPk,
'role_user': roleUser,
};
}

// class Fields {
// Fields({
// this.user,
// this.text,
// this.date,
// this.question,
// this.roleUser,
// });

// List<String> user;
// String text;
// DateTime date;
// int question;
// String roleUser;

// factory Fields.fromJson(Map<String, dynamic> json) => Fields(
// user: List<String>.from(json['user'].map((x) => x)),
// text: json['text'],
// date: DateTime.parse(json['date']),
// question: json['question'],
// roleUser: json['role_user'],
// );

// Map<String, dynamic> toJson() => {
// 'user': List<dynamic>.from(user.map((x) => x)),
// 'text': text,
// 'date': "${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
// 'question': question,
// 'role_user': roleUser,
// };
// }
57 changes: 57 additions & 0 deletions lib/models/tanyabund/question_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'dart:convert';

List<QuestionModel> questionModelFromJson(String str) =>
List<QuestionModel>.from(
json.decode(str).map((x) => QuestionModel.fromJson(x)));

String questionModelToJson(List<QuestionModel> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class QuestionModel {
QuestionModel({
required this.model,
required this.pk,
required this.user,
required this.text,
required this.isAnswered,
required this.date,
required this.totalLike,
required this.totalAnswer,
required this.roleUser,
});

String model;
int pk;
String user;
String text;
bool isAnswered;
DateTime date;
int totalLike;
int totalAnswer;
String roleUser;

factory QuestionModel.fromJson(Map<String, dynamic> json) => QuestionModel(
model: json['model'],
pk: json['pk'],
user: List<String>.from(json['fields']['user'].map((x) => x)).first,
text: json['fields']['text'],
isAnswered: json['fields']['is_answered'],
date: DateTime.parse(json['fields']['date']),
totalLike: json['fields']['total_like'],
totalAnswer: json['fields']['total_answer'],
roleUser: json['fields']['role_user'],
);

Map<String, dynamic> toJson() => {
'model': model,
'pk': pk,
'user': user,
'text': text,
'is_answered': isAnswered,
'date':
"${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
'total_like': totalLike,
'total_answer': totalAnswer,
'role_user': roleUser,
};
}
18 changes: 16 additions & 2 deletions lib/routes/routes_factory.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:endterm_project/views/pages/authentication/_authentication.dart';
import 'package:endterm_project/views/pages/onboarding/_onboarding.dart';
import 'package:flutter/material.dart';
import '../views/pages/_pages.dart';
import 'routes_name.dart';
Expand All @@ -7,11 +9,23 @@ Widget getScreenByName(String name) {
switch (name) {
case RoutesName.home:
return const HomePage();
case RoutesName.signup:
return const SignUpPage();
case RoutesName.login:
return const LoginPage();
case RoutesName.tanyaBund:
return const TanyaBundPage();
return TanyaBundPage();
case RoutesName.catatBund:
return const CatatBundPage();
case RoutesName.catatBundForm:
return const CatatForm();
// Add your page here
case RoutesName.bacaBund:
return const BacaBundPage();
case RoutesName.periksaBund:
return const PeriksaBundPage();
default:
return const HomePage();
return const OnboardingPage();
}
}
}
Loading

0 comments on commit 8070135

Please sign in to comment.