Commit b6c81ee9 authored by fauzienhaa's avatar fauzienhaa
Browse files

update kuliner

parent 349a7f49
No related merge requests found
Showing with 720 additions and 217 deletions
+720 -217
var remoteServerConfiguration = {
"server": "https://otp-wisata.netlify.app/",
"serverKey": "GO123"
};
\ No newline at end of file
......@@ -2,7 +2,8 @@ import 'package:desa_wisata/admin/main_page_admin.dart';
import 'package:desa_wisata/admin/tambah_tiket.dart';
import 'package:desa_wisata/signinsignup.dart';
import 'package:desa_wisata/splash_page.dart';
import 'package:desa_wisata/user/checkout.dart';
import 'package:desa_wisata/user/checkout_kuliner.dart';
import 'package:desa_wisata/user/checkout_wisata.dart';
import 'package:desa_wisata/user/daftar_pesanan_user.dart';
import 'package:desa_wisata/user/dashboard/main_page_user.dart';
import 'package:flutter/material.dart';
......@@ -37,7 +38,8 @@ class MyApp extends StatelessWidget {
'/home-admin': ((context) => MainPageAdmin()),
'/tambah-tiket': ((context) => TambahTiket()),
'/home-user': ((context) => MainPageUser()),
'/checkout': ((context) => CheckOut()),
'/checkout_wisata': ((context) => CheckOut_Wisata()),
'/checkout_kuliner': ((context) => CheckOut_Kuliner()),
'/DaftarPesananUser': ((context) => DaftarPesananUser()),
},
);
......
......@@ -49,3 +49,7 @@ var cartList = [
// image: 'zTCijV8Ma0ztU5pyyS3vnANFy6SsTVhV4LjMKjpu.jpg'),
];
var cartListKuliner = [
];
import 'package:desa_wisata/auth.config.dart';
import 'package:desa_wisata/data.dart';
import 'package:desa_wisata/theme.dart';
import 'package:shared_preferences/shared_preferences.dart';
......@@ -6,6 +7,8 @@ import 'package:email_auth/email_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
import 'package:smart_auth/smart_auth.dart';
import 'dart:math';
class SignInSignUp2 extends StatefulWidget {
const SignInSignUp2({Key? key}) : super(key: key);
......@@ -14,6 +17,7 @@ class SignInSignUp2 extends StatefulWidget {
_SignInSignUp2State createState() => _SignInSignUp2State();
}
var isLoading = false;
class _SignInSignUp2State extends State<SignInSignUp2> {
......@@ -29,7 +33,25 @@ class _SignInSignUp2State extends State<SignInSignUp2> {
// final _formregKey = GlobalKey<FormState>();
final GlobalKey<FormState> _formregKey = GlobalKey<FormState>();
final _passwordVisible = false;
EmailAuth emailAuth = new EmailAuth(sessionName: "Sample session");
EmailAuth emailAuth = new EmailAuth(sessionName: "Sample session");
bool verified = false;
final smartAuth = SmartAuth();
Random random = new Random();
var otp = 0;
@override
void initState() {
super.initState();
// Initialize the package
emailAuth = new EmailAuth(
sessionName: "Sample session",
);
/// Configuring the remote server
emailAuth.config(remoteServerConfiguration);
}
@override
Widget build(BuildContext context) {
......@@ -715,7 +737,7 @@ class _SignInSignUp2State extends State<SignInSignUp2> {
.fromSTEB(20, 24, 20, 24),
suffixIcon: TextButton(
child: Text("Send OTP"),
onPressed: sendOtp,
onPressed: randomOtp,
)
),
style: bodyText1.copyWith(
......@@ -737,7 +759,15 @@ class _SignInSignUp2State extends State<SignInSignUp2> {
child: TextButton(
onPressed: () {
if (emailValidation(emailSignUpController.text)) {
register();
verifyOtp();
if (verified){
register();
} else {
const snackBar = SnackBar(
content: Text('OTP Salah!'),
backgroundColor: Colors.red,
);
}
setState(() {
isLoading =
true;
......@@ -891,25 +921,68 @@ class _SignInSignUp2State extends State<SignInSignUp2> {
return data;
// return json.decode(response.body);
}
void sendOtp() async {
emailAuth.sessionName= "Test Session";
var res = await emailAuth.sendOtp(recipientMail: emailSignUpController.text, otpLength: 6);
if (res) {
print("OTP Sent");
void randomOtp() async {
setState(() {
otp = random.nextInt(10000);
});
SharedPreferences prefs = await SharedPreferences.getInstance();
http.Response res = await http.post(
Uri.parse("http://127.0.0.1:8000/api/sendEmail"),
headers: <String, String>{
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: jsonEncode(<String, String>{
'email': emailSignUpController.toString(),
'name' : usernameController.toString(),
'code': otp.toString()
}),
);
if (res.statusCode != 200) {
print("otp send failed");
} else {
print("We could not sent OTP");
print("otp sent");
}
}
void verifyOtp() {
var res = emailAuth.validateOtp(recipientMail: emailSignUpController.text, userOtp: otpController.text);
var code = int.parse(otpController.text);
if (otp == code) {
setState(() {
verified = true;
});
print("otp benar");
} else {
print("otp salah");
}
}
void sendOtp() async {
emailAuth.sessionName= "Sample Session";
var res = await emailAuth.sendOtp(recipientMail: emailSignUpController.text, otpLength: 6);
if (res) {
print("OTP Verified");
print("OTP Sent");
} else {
print("OTP not verified");
print("We could not sent OTP");
}
}
// void verifyOtp() {
// var res = emailAuth.validateOtp(recipientMail: emailSignUpController.text, userOtp: otpController.text);
// if (res) {
// print("OTP Verified");
// setState(() {
// verified = true;
// });
// } else {
// print("OTP not verified");
// setState(() {
// verified = false;
// });
// }
// }
Future register() async {
http.Response response = await http.post(
Uri.parse("http://go-wisata.id/api/register"),
......
import 'package:desa_wisata/data.dart';
import 'package:desa_wisata/signinsignup.dart';
import 'package:desa_wisata/signinsignup2.dart';
import 'package:desa_wisata/theme.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AkunUser3 extends StatefulWidget {
const AkunUser3({Key? key}) : super(key: key);
@override
_AkunUser3State createState() => _AkunUser3State();
}
class _AkunUser3State extends State<AkunUser3> {
@override
Widget build(BuildContext context) {
return Scaffold(
// key: scaffoldKey,
backgroundColor: primaryBackground,
appBar: AppBar(
backgroundColor: Colors.white,
automaticallyImplyLeading: false,
title: Text(
'Profile',
style: title1.copyWith(
color: Colors.black
),
),
actions: [],
centerTitle: false,
elevation: 0,
),
body: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
blurRadius: 1,
color: primaryBackground,
offset: Offset(0, 0),
)
],
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(24, 12, 24, 12),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 80,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child:Container(
width: 120,
height: 120,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset(
'assets/image/profil-admin.jpg',
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(16, 0, 0, 0),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 8, 0, 0),
child:
Text(
'Hello Guest',
style: GoogleFonts.montserrat(
color: Color(0xFF090F13),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
],
),
),
),
],
),
Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 20, 0, 20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 80,
height: 40,
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, '/signinsignup');
},
child: Text('Log In',
style: bodyText2.copyWith(
fontFamily: 'Lexend Deca',
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.normal,
),),
style: TextButton.styleFrom(
backgroundColor: Colors.green,
elevation: 1,
side: BorderSide(
color: Colors.transparent,
width: 1,
),
),
),
),
],
),
),
],
),
],
),
);
}
String email = "";
logOut() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
prefs.remove("isLoggedIn");
prefs.remove("loginRole");
prefs.remove("loginId");
prefs.remove("loginName");
prefs.remove("loginEmail");
prefs.remove("loginTelp");
});
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (BuildContext context) => const SignInSignUp2(),
),
(route) => false,
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
"Berhasil logout",
style: TextStyle(fontSize: 16),
)),
);
}
@override
dispose() {
super.dispose();
}
}
This diff is collapsed.
......@@ -7,14 +7,14 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
class CheckOut extends StatefulWidget {
const CheckOut({Key? key}) : super(key: key);
class CheckOut_Wisata extends StatefulWidget {
const CheckOut_Wisata({Key? key}) : super(key: key);
@override
_CheckOutState createState() => _CheckOutState();
_CheckOut_WisataState createState() => _CheckOut_WisataState();
}
class _CheckOutState extends State<CheckOut> {
class _CheckOut_WisataState extends State<CheckOut_Wisata> {
DateTime? datePicked;
bool checkoutIsProcessing = false;
final scaffoldKey = GlobalKey<ScaffoldState>();
......
......@@ -135,13 +135,15 @@ class _dataWidgetState extends State<dataWidget> {
padding: EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
child: InkWell(
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// MainPageUser(),
// ),
// );
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Daftar_EventUser(
idEvent: widget.snapshot.data[widget.index]['id']
.toString(),
indexEvent: widget.index,
),
));
},
child: Container(
width: 270,
......
......@@ -13,7 +13,7 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../checkout.dart';
import '../../checkout_wisata.dart';
class Daftar_EventUser extends StatefulWidget {
const Daftar_EventUser({
......
import 'package:desa_wisata/models/cart.dart';
import 'package:desa_wisata/models/menu_model.dart';
import 'package:desa_wisata/theme.dart';
import 'package:desa_wisata/user/checkout_kuliner.dart';
import 'dart:collection';
import 'dart:convert';
......@@ -13,7 +14,7 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../checkout.dart';
import '../../checkout_wisata.dart';
class Daftar_KulinerUser extends StatefulWidget {
const Daftar_KulinerUser(
......@@ -80,7 +81,7 @@ class _Daftar_KulinerUserState extends State<Daftar_KulinerUser> {
// harga: int.parse(snapshot.data![index].harga ),
harga: snapshot.data![index].harga ?? 0,
image: snapshot.data![index].image);
cartList.add(c1);
cartListKuliner.add(c1);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
});
},
......@@ -145,6 +146,7 @@ class _Daftar_KulinerUserState extends State<Daftar_KulinerUser> {
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0, 0, 3),
......@@ -175,13 +177,59 @@ class _Daftar_KulinerUserState extends State<Daftar_KulinerUser> {
// return Text('Data Error');
}),
floatingActionButton: Container(
width: MediaQuery.of(context).size.width * 0.9,
height: 100,
child: Card(
color: Color(0xFFFFF8EC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Total",
style: bodyText1.copyWith(
color: Colors.blue,
fontSize: 20,
),
),
Text(
"Rp. " + getTotalKuliner().toString(),
),
],
),
),
Spacer(),
Padding(
padding: const EdgeInsets.all(20.0),
child: FloatingActionButton.extended(
onPressed: () {
// Add your onPressed code here!
Navigator.pushNamed(context, '/checkout_kuliner');
},
label: Text('Cart'),
backgroundColor: Colors.blue,
icon: const Icon(Icons.shopping_cart),
// child: const Icon(Icons.shopping_cart),
),
),
],
),
),
),
//
);
}
final String baseUrl = 'http://go-wisata.id/';
final String apiUrl = 'http://go-wisata.id/api/listevent/';
final String apiUrl = 'http://go-wisata.id/api/kuliner/';
Future<List<Map<String, dynamic>>?> fetch() async {
http.Response response = await http
......
......@@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../checkout.dart';
import '../../checkout_wisata.dart';
class DaftarPenginapanUser extends StatefulWidget {
const DaftarPenginapanUser({Key? key}) : super(key: key);
......
......@@ -64,7 +64,7 @@ class _DaftarWahanaUserState extends State<DaftarWahanaUser> {
),
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, '/checkout');
Navigator.pushNamed(context, '/checkout_wisata');
},
style: TextButton.styleFrom(
backgroundColor: Colors.blue,
......
......@@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <smart_auth/smart_auth_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) smart_auth_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SmartAuthPlugin");
smart_auth_plugin_register_with_registrar(smart_auth_registrar);
}
......@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
smart_auth
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
......
......@@ -7,8 +7,10 @@ import Foundation
import path_provider_macos
import shared_preferences_macos
import smart_auth
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin"))
}
......@@ -392,6 +392,13 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
smart_auth:
dependency: "direct main"
description:
name: smart_auth
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
smooth_page_indicator:
dependency: "direct main"
description:
......
......@@ -51,6 +51,7 @@ dependencies:
smooth_page_indicator: 1.0.0+2
flutter_animate: ^2.0.0
email_auth: ^1.0.0
smart_auth: ^1.0.6
dev_dependencies:
......
......@@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <smart_auth/smart_auth_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
SmartAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SmartAuthPlugin"));
}
......@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
smart_auth
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
......
Markdown is supported
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