diff --git a/lib/main.dart b/lib/main.dart index c4eeba3..f31bdc9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:trashsure/pages/SplashPage.dart'; import 'pages/LoginPage.dart'; import 'pages/RegisterPage.dart'; -import 'package:trashsure/pages/user/DepositAddPage.dart'; import 'package:trashsure/pages/LandingPage.dart'; -import 'package:trashsure/pages/user/TestimoniAddPage.dart'; import 'package:trashsure/pages/user/WithdrawAddPage.dart'; import 'package:trashsure/utils/auth.dart'; import 'package:provider/provider.dart'; @@ -36,19 +34,16 @@ class MyApp extends StatelessWidget { routes: { "/splash": (BuildContext context) => const SplashPage(), "/landing": (BuildContext context) => const LandingPage(), - "/admin": (BuildContext context) => const AdminPage(idx: 0), + "/admin": (BuildContext context) => const AdminPage(idx: 1), "/admin/deposit/add": (BuildContext context) => const AdminAddDepositPage(), "/admin/prize/add": (BuildContext context) => const AdminAddPrizePage(), "/login": (BuildContext context) => const LoginPage(), "/register": (BuildContext context) => const RegisterPage(), - "/user": (BuildContext context) => const UserPage(idx: 0), + "/user": (BuildContext context) => const UserPage(idx: 1), "/user/withdraw/add": (BuildContext context) => const WithdrawAddPage(), - "/user/deposit/add": (BuildContext context) => const DepositAddPage(), - "/user/testimoni/add": (BuildContext context) => - const TestimoniAddPage(), }, ), ); diff --git a/lib/pages/LandingPage.dart b/lib/pages/LandingPage.dart index f776c54..693f691 100644 --- a/lib/pages/LandingPage.dart +++ b/lib/pages/LandingPage.dart @@ -1,10 +1,8 @@ // ignore_for_file: file_names - import 'package:flutter/material.dart'; import 'LoginPage.dart'; import 'RegisterPage.dart'; import 'package:trashsure/utils/auth.dart'; -import 'package:trashsure/utils/useTestimoni.dart'; import 'package:provider/provider.dart'; class LandingPage extends StatefulWidget { @@ -17,20 +15,17 @@ class LandingPage extends StatefulWidget { class _LandingPageState extends State { final ScrollController controller = ScrollController(); - UseTestimoni useTestimoni = UseTestimoni(); - - void scrollDown() { - // Method buat automatically scroll down saat tombol dipencet - controller.animateTo( - controller.position.maxScrollExtent, - duration: const Duration(seconds: 2), - curve: Curves.fastOutSlowIn, - ); - } - @override Widget build(BuildContext context) { final request = context.watch(); + final double screenHeight = MediaQuery.of(context).size.height; + void scrollDown() { + controller.animateTo( + controller.offset + screenHeight, + duration: const Duration(seconds: 2), + curve: Curves.fastOutSlowIn, + ); + } return SafeArea( child: Scaffold( @@ -40,7 +35,7 @@ class _LandingPageState extends State { children: [ Container( width: double.infinity, - height: MediaQuery.of(context).size.height, + height: screenHeight, color: Colors.black, child: Stack( children: [ @@ -119,7 +114,7 @@ class _LandingPageState extends State { scrollDown(); }, child: const Text( - "Lihat Testimoni", + "Pelajari lebih lanjut", ), ), ), @@ -168,7 +163,7 @@ class _LandingPageState extends State { ), ), Container( - padding: const EdgeInsets.all(20), + padding: const EdgeInsets.fromLTRB(20, 20, 20, 80), width: double.infinity, color: const Color.fromARGB(255, 245, 245, 245), child: Column( @@ -268,149 +263,6 @@ class _LandingPageState extends State { ], ), ), - Container( - padding: const EdgeInsets.all(20), - width: double.infinity, - color: const Color.fromARGB(255, 245, 245, 245), - child: Column(children: [ - const Text( - "Testimoni", - style: TextStyle( - fontSize: 30, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - if (request.loggedIn) - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: 150, - child: TextButton( - style: ButtonStyle( - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18), - side: const BorderSide( - color: Colors.green))), - ), - onPressed: () { - // scrollDown(); - Navigator.pushNamed( - context, '/user/testimoni/add'); - }, - child: const Text( - "Tambah Testimoni", - ), - ), - ), - ], - ), - Column( - children: [ - FutureBuilder( - future: useTestimoni.fetchTestimoni(), - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.data == null) { - return const Center( - child: CircularProgressIndicator()); - } else { - if (!snapshot.data.isNotEmpty) { - return Container( - alignment: Alignment.center, - margin: EdgeInsets.symmetric( - vertical: - MediaQuery.of(context).size.height / - 10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Icon( - Icons.message_outlined, - size: 50, - ), - SizedBox( - height: 20, - ), - Text( - "Belum ada testimoni", - style: TextStyle( - color: Colors.grey, - fontSize: 16, - ), - ), - ], - ), - ); - } else { - return ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: - const NeverScrollableScrollPhysics(), - itemCount: snapshot.data!.length, - itemBuilder: (_, index) => Container( - margin: const EdgeInsets.symmetric( - horizontal: 16, vertical: 12), - padding: const EdgeInsets.all(20.0), - decoration: BoxDecoration( - color: const Color.fromARGB( - 255, 226, 215, 132), - borderRadius: - BorderRadius.circular(15.0), - boxShadow: const [ - BoxShadow( - color: Colors.black, - blurRadius: 2.0) - ]), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Column( - children: [ - RichText( - textAlign: - TextAlign.center, - text: TextSpan( - text: - "${snapshot.data![index].fields.desc}\n", - style: - const TextStyle( - color: Colors - .black, - fontSize: - 18))), - Text( - "${snapshot.data![index].fields.username}", - style: const TextStyle( - color: Colors.black, - fontSize: 12.0, - fontWeight: - FontWeight.bold, - ), - ), - const SizedBox(height: 4), - ], - ), - ], - ), - )); - } - } - }), - if (!request.loggedIn) - const SizedBox( - height: 60, - ) - ], - ), - ]), - ), ], ), ), @@ -514,21 +366,6 @@ class _PageViewCustomState extends State { "AMAN", "Pengelolaan data dilakukan secara aman dan rahasia untuk segala transaksi." ], - [ - Icons.mobile_friendly_outlined, - "MOBILE SUPPORT", - "Transaksi dapat dilakukan dengan mudah dan nyaman melalui aplikasi mobile." - ], - [ - Icons.integration_instructions_outlined, - "TERINTEGRASI", - "Data Bank Sampah yang tergabung sudah terintegrasi memudahkan proses pemantauan pengelolaan sampah." - ], - [ - Icons.card_giftcard, - "SISTEM POIN", - "TrashSure juga memberikan poin yang dapat anda kumpulkan dan tukarkan dengan hadiah menarik." - ] ]; @override @@ -550,19 +387,11 @@ class _PageViewCustomState extends State { controller: pageController, itemCount: listItem.length, itemBuilder: ((context, index) { - double angle = (pageOffset! - index).abs(); - - if (angle > 0.5) { - angle = 1 - angle; - } return Transform( - transform: Matrix4.identity() - ..setEntry(3, 2, 0.001) - ..rotateY(angle), + transform: Matrix4.identity()..setEntry(3, 2, 0.001), alignment: Alignment.center, child: Material( color: const Color.fromARGB(255, 245, 245, 245), - elevation: 1, child: Container( margin: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.all(30), diff --git a/lib/pages/LoginPage.dart b/lib/pages/LoginPage.dart index 6809a7c..396d653 100644 --- a/lib/pages/LoginPage.dart +++ b/lib/pages/LoginPage.dart @@ -166,12 +166,10 @@ class _LoginPageState extends State { }); _formKey.currentState?.save(); final response = await request - .login( - "https://trashsure.iyoubee.xyz/flutter/login/", - { - 'username': _email, - 'password': _password, - }) + .login({ + 'username': _email, + 'password': _password, + }) .then((value) => { if (value['status'] == 200) { diff --git a/lib/pages/RegisterPage.dart b/lib/pages/RegisterPage.dart index 8be2d57..c8fdd3c 100644 --- a/lib/pages/RegisterPage.dart +++ b/lib/pages/RegisterPage.dart @@ -166,16 +166,16 @@ class _RegisterPageState extends State { }); _formKey.currentState?.save(); final response = await request - .post( - "https://trashsure.iyoubee.xyz/flutter/register/", - { - 'username': _email, - 'password': _password, - }) + .register({ + 'username': _email, + 'password': _password, + }) .then((value) => { if (value['status'] == 200) { - Navigator.pop(context), + Navigator + .pushReplacementNamed( + context, '/user'), Flushbar( backgroundColor: const Color.fromARGB( diff --git a/lib/pages/SplashPage.dart b/lib/pages/SplashPage.dart index 064eb72..4344035 100644 --- a/lib/pages/SplashPage.dart +++ b/lib/pages/SplashPage.dart @@ -1,7 +1,5 @@ // ignore_for_file: file_names, use_build_context_synchronously -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:trashsure/pages/LandingPage.dart'; import 'package:trashsure/pages/user/UserPage.dart'; @@ -25,13 +23,16 @@ class _SplashPageState extends State { void _checkLoggedInAndNavigate() async { final request = context.read(); await request.init(); - log("init ${request.cookies}"); if (request.loggedIn) { + await Future.delayed(const Duration( + seconds: 3)); // Add a 3-second delay// Add a small delay Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const UserPage(idx: 0)), ); } else { + await Future.delayed(const Duration( + seconds: 3)); // Add a 3-second delay // Add a small delay Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const LandingPage()), @@ -39,10 +40,47 @@ class _SplashPageState extends State { } } + bool loadingBallAppear = false; + double loadingBallSize = 1; + @override Widget build(BuildContext context) { - return const Center( - child: CircularProgressIndicator(), // Display a loading indicator - ); + return Scaffold( + backgroundColor: const Color.fromARGB(255, 245, 245, 245), + resizeToAvoidBottomInset: true, + body: SafeArea( + bottom: false, + child: Stack( + children: [ + AnimatedAlign( + duration: const Duration(milliseconds: 300), + alignment: Alignment.center, + child: TweenAnimationBuilder( + duration: const Duration(milliseconds: 500), + tween: Tween(begin: 0, end: loadingBallSize), + onEnd: () { + setState(() { + if (loadingBallSize == 1) { + loadingBallSize = 1.5; + } else { + loadingBallSize = 1; + } + }); + }, + builder: (_, value, __) => Transform.scale( + scale: value, + child: Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.black.withOpacity(0.8), + shape: BoxShape.circle, + ), + child: null), + ), + ), + ), + ], + ))); } } diff --git a/lib/pages/user/DepositAddPage.dart b/lib/pages/user/DepositAddPage.dart deleted file mode 100644 index 95f82a0..0000000 --- a/lib/pages/user/DepositAddPage.dart +++ /dev/null @@ -1,256 +0,0 @@ -// ignore_for_file: use_build_context_synchronously, prefer_typing_uninitialized_variables, file_names - -import 'package:another_flushbar/flushbar.dart'; -import 'package:trashsure/pages/user/UserPage.dart'; -import 'package:trashsure/utils/auth.dart'; -import 'package:provider/provider.dart'; -import 'package:flutter/material.dart'; -import 'package:trashsure/utils/useUserDeposit.dart'; - -class DepositAddPage extends StatefulWidget { - const DepositAddPage({super.key}); - - @override - State createState() => _DepositAddPage(); -} - -class _DepositAddPage extends State { - final GlobalKey _formKey = GlobalKey(); - - UseUserDeposit useUserDeposit = UseUserDeposit(); - - var _jenis; - String berat = ""; - - void _submit(context, request) { - showDialog( - context: context, - barrierDismissible: true, // user can tap anywhere to close the pop up - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Konfirmasi'), - content: SingleChildScrollView( - child: Column( - children: [ - const Align( - alignment: Alignment.topLeft, - child: Text("Jenis sampah:", - style: TextStyle(fontWeight: FontWeight.w700))), - Align( - alignment: Alignment.topLeft, - child: Text(_jenis), - ), - const SizedBox( - height: 10, - ), - const Align( - alignment: Alignment.topLeft, - child: Text("Berat total:", - style: TextStyle(fontWeight: FontWeight.w700))), - Align( - alignment: Alignment.topLeft, - child: Text("$berat Kg"), - ) - ], - ), - ), - actions: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: TextButton.styleFrom( - foregroundColor: Colors.white, - backgroundColor: Colors.grey, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), - ), - child: const Text('Batal'), - onPressed: () { - Navigator.pop(context); - }, // so the alert dialog is closed when navigating back to main page - ), - TextButton( - style: TextButton.styleFrom( - foregroundColor: Colors.white, - backgroundColor: Colors.blue, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), - ), - child: const Text('Konfirmasi'), - onPressed: () async { - int response = await useUserDeposit.addDeposit( - context, request, _jenis, berat); - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute( - builder: (context) => const UserPage(idx: 1)), - (route) => false); - if (response == 200) { - Flushbar( - backgroundColor: const Color.fromARGB(255, 29, 167, 86), - flushbarPosition: FlushbarPosition.TOP, - title: "Berhasil", - duration: const Duration(seconds: 3), - message: "Deposit berhasil dibuat", - ).show(context); - } else { - Flushbar( - backgroundColor: - const Color.fromARGB(255, 244, 105, 77), - flushbarPosition: FlushbarPosition.TOP, - title: "Gagal", - duration: const Duration(seconds: 3), - message: "Ada yang salah", - ).show(context); - } - }, - ) - ], - ) - ], - ); - }, - ); - } - - @override - Widget build(BuildContext context) { - final request = context.watch(); - return Scaffold( - backgroundColor: const Color.fromARGB(255, 245, 245, 245), - appBar: AppBar( - backgroundColor: const Color.fromARGB(255, 245, 245, 245), - elevation: 0, - iconTheme: const IconThemeData(color: Colors.black), - actions: [ - GestureDetector( - child: IconButton( - icon: const Icon( - Icons.autorenew, - color: Colors.black, - ), - onPressed: () { - // do something - }, - ), - ), - ], - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - const Align( - alignment: Alignment.topLeft, - child: Text("Masukan Data Deposit", - style: TextStyle( - fontSize: 24, - )), - ), - const SizedBox( - height: 20, - ), - Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - DropdownButtonFormField( - decoration: const InputDecoration( - enabledBorder: OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(20.0)), - borderSide: - BorderSide(color: Colors.black, width: 1.0), - ), - border: OutlineInputBorder()), - // ignore: prefer_const_literals_to_create_immutables - items: [ - const DropdownMenuItem( - value: "Plastik", - child: Text("Plastik"), - ), - const DropdownMenuItem( - value: "Elektronik", - child: Text("Elektronik"), - ) - ], - hint: const Text("Jenis Sampah"), - onChanged: (value) { - setState(() { - _jenis = value; - // measureList.add(measure); - }); - }, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Pilih jenis sampah'; - } - return null; - }, - onSaved: (value) { - setState(() { - _jenis = value; - }); - }), - const SizedBox( - height: 20, - ), - TextFormField( - decoration: const InputDecoration( - labelText: 'Berat total (Kg)', - enabledBorder: OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(20.0)), - borderSide: - BorderSide(color: Colors.black, width: 1.0), - ), - border: OutlineInputBorder()), - keyboardType: TextInputType.number, - validator: (value) { - if (value == null || - value.isEmpty || - value.contains(RegExp(r'^[a-zA-Z\-]'))) { - return 'Use only numbers!'; - } - return null; - }, - onFieldSubmitted: (value) { - setState(() { - berat = value; - // bodyTempList.add(bodyTemp); - }); - }, - onChanged: (value) { - setState(() { - berat = value; - }); - }, - ), - const SizedBox( - height: 20, - ), - ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - const Color.fromARGB(255, 5, 89, 91), - minimumSize: const Size.fromHeight(60)), - onPressed: () { - // Validate returns true if the form is valid, or false otherwise. - if (_formKey.currentState!.validate()) { - _submit(context, request); - } - }, - child: const Text("Submit"), - ), - ], - ), - ), - ], - ), - ), - )); - } -} diff --git a/lib/pages/user/TestimoniAddPage.dart b/lib/pages/user/TestimoniAddPage.dart deleted file mode 100644 index 23a90e4..0000000 --- a/lib/pages/user/TestimoniAddPage.dart +++ /dev/null @@ -1,210 +0,0 @@ -// ignore_for_file: file_names, use_build_context_synchronously, unused_local_variable - -import 'package:another_flushbar/flushbar.dart'; -import 'package:flutter/material.dart'; -import 'package:trashsure/utils/useTestimoni.dart'; -import 'package:trashsure/utils/auth.dart'; -import 'package:provider/provider.dart'; - -class TestimoniAddPage extends StatefulWidget { - const TestimoniAddPage({super.key}); - - @override - State createState() => _TestimoniAddPageState(); -} - -class _TestimoniAddPageState extends State { - final GlobalKey _formKey = GlobalKey(); - - UseTestimoni useTestimoni = UseTestimoni(); - - String poin = ""; - String judul = ""; - String stok = ""; - String desc = ""; - - void _submit(context, request) { - showDialog( - context: context, - barrierDismissible: true, // user can tap anywhere to close the pop up - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Konfirmasi'), - content: SingleChildScrollView( - child: Column( - children: const [ - Align( - alignment: Alignment.topLeft, - child: Text("Anda yakin?", - style: TextStyle(fontWeight: FontWeight.w700))), - ], - ), - ), - actions: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: TextButton.styleFrom( - foregroundColor: Colors.white, - backgroundColor: Colors.grey, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), - ), - child: const Text('Batal'), - onPressed: () { - Navigator.pop(context); - }, // so the alert dialog is closed when navigating back to main page - ), - TextButton( - style: TextButton.styleFrom( - foregroundColor: Colors.white, - backgroundColor: Colors.blue, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), - ), - child: const Text('Konfirmasi'), - onPressed: () async { - final response = await useTestimoni - .addTestimoni(context, request, desc) - .then((value) => { - Navigator.pop(context), - if (value['status'] == 200) - { - Navigator.pop(context), - Flushbar( - backgroundColor: - const Color.fromARGB(255, 29, 167, 86), - flushbarPosition: FlushbarPosition.TOP, - title: "Berhasil", - duration: const Duration(seconds: 3), - message: value['message'], - ).show(context), - } - else - { - Navigator.pop(context), - Flushbar( - backgroundColor: - const Color.fromARGB(255, 244, 105, 77), - flushbarPosition: FlushbarPosition.TOP, - title: "Gagal", - duration: const Duration(seconds: 3), - message: value['message'], - ).show(context), - } - }); - FocusScope.of(context) - .unfocus(); // Unfocus the last selected input field - _formKey.currentState?.reset(); - setState(() {}); - }, - ) - ], - ) - ], - ); - }, - ); - } - - @override - Widget build(BuildContext context) { - final request = context.watch(); - return Scaffold( - backgroundColor: const Color.fromARGB(255, 245, 245, 245), - appBar: AppBar( - backgroundColor: const Color.fromARGB(255, 245, 245, 245), - elevation: 0, - iconTheme: const IconThemeData(color: Colors.black), - actions: [ - GestureDetector( - child: IconButton( - icon: const Icon( - Icons.autorenew, - color: Colors.black, - ), - onPressed: () { - // do something - }, - ), - ), - ], - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - const Align( - alignment: Alignment.topLeft, - child: Text("Masukan Testimoni", - style: TextStyle( - fontSize: 24, - )), - ), - const SizedBox( - height: 20, - ), - Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextFormField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: const InputDecoration( - labelText: 'Testimoni', - enabledBorder: OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(20.0)), - borderSide: - BorderSide(color: Colors.black, width: 1.0), - ), - border: OutlineInputBorder()), - onFieldSubmitted: (value) { - setState(() { - desc = value; - // firstNameList.add(firstName); - }); - }, - onChanged: (value) { - setState(() { - desc = value; - }); - }, - validator: (value) { - if (value == null || - value.isEmpty || - value.length < 3) { - return 'Testimoni must contain at least 3 characters'; - } - return null; - }, - ), - const SizedBox( - height: 20, - ), - ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - const Color.fromARGB(255, 5, 89, 91), - minimumSize: const Size.fromHeight(60)), - onPressed: () { - // Validate returns true if the form is valid, or false otherwise. - if (_formKey.currentState!.validate()) { - _submit(context, request); - } - }, - child: const Text("Submit"), - ), - ], - ), - ), - ], - ), - ), - )); - } -} diff --git a/lib/pages/user/UserPage.dart b/lib/pages/user/UserPage.dart index 74b45c6..3298931 100644 --- a/lib/pages/user/UserPage.dart +++ b/lib/pages/user/UserPage.dart @@ -34,7 +34,6 @@ class _UserPageState extends State { List _widgetOptions = [ LandingPage(), DepositPage(), - // NOTE: Redeem Prize Page RedeemPrizePage(), WithdrawPage(), ]; diff --git a/lib/utils/auth.dart b/lib/utils/auth.dart index 983ab63..df8bb3a 100644 --- a/lib/utils/auth.dart +++ b/lib/utils/auth.dart @@ -37,7 +37,8 @@ class CookieRequest { local.setString("cookies", cookies); } - Future login(String url, dynamic data) async { + Future login(dynamic data) async { + String url = "http://192.168.56.1:8000/api/login"; if (kIsWeb) { dynamic c = _client; c.withCredentials = true; @@ -59,6 +60,24 @@ class CookieRequest { return json.decode(response.body); } + Future register(dynamic data) async { + String url = "http://192.168.56.1:8000/api/register"; + if (kIsWeb) { + dynamic c = _client; + c.withCredentials = true; + } + + http.Response response = + await _client.post(Uri.parse(url), body: data, headers: headers); + + if (response.statusCode == 200) { + http.Response response = await login(data); + return json.decode(response.body); + } else { + return json.decode(response.body); + } + } + Map getJsonData() { return jsonData; } diff --git a/lib/utils/useTestimoni.dart b/lib/utils/useTestimoni.dart deleted file mode 100644 index 435b5a6..0000000 --- a/lib/utils/useTestimoni.dart +++ /dev/null @@ -1,32 +0,0 @@ -// ignore_for_file: file_names - -import 'package:trashsure/models/Testimoni.dart'; -import 'package:http/http.dart' as http; -import 'dart:convert'; - -class UseTestimoni { - Future> fetchTestimoni() async { - var url = Uri.parse('https://trashsure.iyoubee.xyz/testimoni/get'); - var response = await http.get(url); - // melakukan decode response menjadi bentuk json - var data = jsonDecode(utf8.decode(response.bodyBytes)); - // melakukan konversi data json menjadi object ToDo - List listTestimoni = []; - for (var d in data) { - if (d != null) { - listTestimoni.add(Testimoni.fromJson(d)); - } - } - - return listTestimoni; - } - - Future addTestimoni(context, request, desc) async { - var response = await request - .post('https://trashsure.iyoubee.xyz/flutter/user/testimoni/add/', { - "desc": desc, - }); - - return response; - } -}