bugs fixed
This commit is contained in:
parent
cf3abae5f8
commit
770a9e2e85
|
|
@ -13,9 +13,10 @@ class CustomTextField extends StatefulWidget {
|
||||||
required this.inputType,
|
required this.inputType,
|
||||||
required this.isPassword,
|
required this.isPassword,
|
||||||
this.contentPadding,
|
this.contentPadding,
|
||||||
|
required this.errorText,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String labelText, hintText;
|
final String labelText, hintText, errorText;
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
bool obscureText, isPassword;
|
bool obscureText, isPassword;
|
||||||
final TextInputType inputType;
|
final TextInputType inputType;
|
||||||
|
|
@ -45,6 +46,8 @@ class _CustomTextFieldState extends State<CustomTextField> {
|
||||||
),
|
),
|
||||||
labelText: widget.labelText,
|
labelText: widget.labelText,
|
||||||
hintText: widget.hintText,
|
hintText: widget.hintText,
|
||||||
|
// errorText: widget.errorText,
|
||||||
|
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(10.adaptedPx()),
|
borderRadius: BorderRadius.circular(10.adaptedPx()),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:sapaly_shop/constants/utils.dart';
|
import 'package:sapaly_shop/constants/utils.dart';
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
controller: emailController,
|
controller: emailController,
|
||||||
labelText: 'email'.translation,
|
labelText: 'email'.translation,
|
||||||
hintText: 'gurbanov@gmail.com'.translation,
|
hintText: 'gurbanov@gmail.com'.translation,
|
||||||
|
errorText: 'enter_valid_email'.translation,
|
||||||
isPassword: false,
|
isPassword: false,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
inputType: TextInputType.emailAddress,
|
inputType: TextInputType.emailAddress,
|
||||||
|
|
@ -112,6 +113,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
labelText: 'password'.translation,
|
labelText: 'password'.translation,
|
||||||
hintText: 'enter_your_password'.translation,
|
hintText: 'enter_your_password'.translation,
|
||||||
|
errorText: 'password_length_8'.translation,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
isPassword: true,
|
isPassword: true,
|
||||||
inputType: TextInputType.visiblePassword,
|
inputType: TextInputType.visiblePassword,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class _LoginScreenState extends State<RegisterScreen> {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 15.adaptedPx(),
|
vertical: 10.adaptedPx(),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
@ -105,11 +105,12 @@ class _LoginScreenState extends State<RegisterScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 15.adaptedPx()),
|
padding: EdgeInsets.only(bottom: 10.adaptedPx()),
|
||||||
child: CustomTextField(
|
child: CustomTextField(
|
||||||
controller: emailController,
|
controller: emailController,
|
||||||
labelText: 'email'.translation,
|
labelText: 'email'.translation,
|
||||||
hintText: 'gurbanov@gmail.com'.translation,
|
hintText: 'gurbanov@gmail.com'.translation,
|
||||||
|
errorText: 'enter_valid_email'.translation,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
isPassword: false,
|
isPassword: false,
|
||||||
inputType: TextInputType.emailAddress,
|
inputType: TextInputType.emailAddress,
|
||||||
|
|
@ -124,11 +125,12 @@ class _LoginScreenState extends State<RegisterScreen> {
|
||||||
inputFormatters: [maskFormatterPhone],
|
inputFormatters: [maskFormatterPhone],
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 15.adaptedPx()),
|
padding: EdgeInsets.symmetric(vertical: 10.adaptedPx()),
|
||||||
child: CustomTextField(
|
child: CustomTextField(
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
labelText: 'password'.translation,
|
labelText: 'password'.translation,
|
||||||
hintText: 'enter_your_password'.translation,
|
hintText: 'enter_your_password'.translation,
|
||||||
|
errorText: 'password_length_8'.translation,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
isPassword: true,
|
isPassword: true,
|
||||||
inputType: TextInputType.visiblePassword,
|
inputType: TextInputType.visiblePassword,
|
||||||
|
|
@ -139,6 +141,7 @@ class _LoginScreenState extends State<RegisterScreen> {
|
||||||
controller: passwordConfirmationController,
|
controller: passwordConfirmationController,
|
||||||
labelText: 'repeat_password'.translation,
|
labelText: 'repeat_password'.translation,
|
||||||
hintText: 'repeat_password_to_confirm'.translation,
|
hintText: 'repeat_password_to_confirm'.translation,
|
||||||
|
errorText: 'password_no_match'.translation,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
isPassword: true,
|
isPassword: true,
|
||||||
inputType: TextInputType.visiblePassword,
|
inputType: TextInputType.visiblePassword,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var me = Provider.of<UserProvider>(context, listen: false);
|
var me = Provider.of<UserProvider>(context, listen: false);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
drawer: SapalyDrawer(),
|
drawer: const SapalyDrawer(),
|
||||||
backgroundColor: AppTheme.lightBackgroundColor,
|
backgroundColor: AppTheme.lightBackgroundColor,
|
||||||
appBar: SapalyAppBar(
|
appBar: SapalyAppBar(
|
||||||
hasActionButton: true,
|
hasActionButton: true,
|
||||||
|
|
@ -86,6 +86,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
||||||
CustomTextField(
|
CustomTextField(
|
||||||
labelText: 'first_name'.translation,
|
labelText: 'first_name'.translation,
|
||||||
hintText: 'first_name'.translation,
|
hintText: 'first_name'.translation,
|
||||||
|
errorText: 'required_field'.translation,
|
||||||
controller: firstNameController,
|
controller: firstNameController,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
inputType: TextInputType.text,
|
inputType: TextInputType.text,
|
||||||
|
|
@ -99,6 +100,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
||||||
child: CustomTextField(
|
child: CustomTextField(
|
||||||
labelText: 'email'.translation,
|
labelText: 'email'.translation,
|
||||||
hintText: 'email'.translation,
|
hintText: 'email'.translation,
|
||||||
|
errorText: 'required_field'.translation,
|
||||||
controller: emailController,
|
controller: emailController,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
inputType: TextInputType.emailAddress,
|
inputType: TextInputType.emailAddress,
|
||||||
|
|
@ -109,6 +111,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
||||||
CustomTextField(
|
CustomTextField(
|
||||||
labelText: 'subject'.translation,
|
labelText: 'subject'.translation,
|
||||||
hintText: 'subject'.translation,
|
hintText: 'subject'.translation,
|
||||||
|
errorText: 'required_field'.translation,
|
||||||
controller: subjectController,
|
controller: subjectController,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
inputType: TextInputType.text,
|
inputType: TextInputType.text,
|
||||||
|
|
@ -124,6 +127,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
||||||
child: CustomTextField(
|
child: CustomTextField(
|
||||||
labelText: 'message'.translation,
|
labelText: 'message'.translation,
|
||||||
hintText: 'message'.translation,
|
hintText: 'message'.translation,
|
||||||
|
errorText: 'required_field'.translation,
|
||||||
controller: messageController,
|
controller: messageController,
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
inputType: TextInputType.text,
|
inputType: TextInputType.text,
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ import 'package:sapaly_shop/features/screens/home/home_screen.dart';
|
||||||
import 'package:sapaly_shop/features/screens/settings/settings_screen.dart';
|
import 'package:sapaly_shop/features/screens/settings/settings_screen.dart';
|
||||||
import 'package:sapaly_shop/features/services/page_navigator.dart';
|
import 'package:sapaly_shop/features/services/page_navigator.dart';
|
||||||
import 'package:sapaly_shop/features/services/requests.dart';
|
import 'package:sapaly_shop/features/services/requests.dart';
|
||||||
import 'package:sapaly_shop/features/widgets/sapaly_icon.dart';
|
|
||||||
import 'package:sapaly_shop/models/category_model.dart';
|
import 'package:sapaly_shop/models/category_model.dart';
|
||||||
import 'package:sapaly_shop/models/settings_model.dart';
|
import 'package:sapaly_shop/models/settings_model.dart';
|
||||||
import 'package:sapaly_shop/providers/user_provider.dart';
|
import 'package:sapaly_shop/providers/user_provider.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
import '../../../constants/global_variables.dart';
|
import '../../../constants/global_variables.dart';
|
||||||
|
|
@ -28,7 +28,7 @@ import '../../../themes/app_theme.dart';
|
||||||
import 'about_us.dart';
|
import 'about_us.dart';
|
||||||
|
|
||||||
class SapalyDrawer extends StatefulWidget {
|
class SapalyDrawer extends StatefulWidget {
|
||||||
SapalyDrawer({super.key});
|
const SapalyDrawer({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SapalyDrawer> createState() => _SapalyDrawerState();
|
State<SapalyDrawer> createState() => _SapalyDrawerState();
|
||||||
|
|
@ -89,7 +89,8 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var settings = Provider.of<SettingsModel>(context, listen: false);
|
var settings = Provider.of<SettingsModel>(context, listen: false);
|
||||||
var me = Provider.of<UserProvider>(context, listen: false);
|
var me = Provider.of<UserProvider>(context, listen: false).user;
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
backgroundColor: AppTheme.whiteColor,
|
backgroundColor: AppTheme.whiteColor,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
@ -111,21 +112,19 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
SizedBox(width: 10.adaptedPx()),
|
SizedBox(width: 10.adaptedPx()),
|
||||||
Text(
|
Text(
|
||||||
GlobalVariables.kAppName,
|
GlobalVariables.kAppName,
|
||||||
style: GoogleFonts.poppins(
|
style: Theme.of(context)
|
||||||
textStyle: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
.primaryTextTheme
|
||||||
.bodyMedium!
|
.bodyMedium
|
||||||
.copyWith(
|
?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
fontSize: 18.adaptedPx(),
|
fontSize: 18.adaptedPx(),
|
||||||
color: AppTheme.blackColor,
|
color: AppTheme.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
me.user.user.email.isEmpty
|
me.token.isEmpty
|
||||||
? Container()
|
? Container()
|
||||||
: GestureDetector(
|
: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
@ -136,13 +135,13 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.account_circle,
|
Icons.account_circle,
|
||||||
size: 35.adaptedPx(),
|
size: 45.adaptedPx(),
|
||||||
color: AppTheme.lightPrimaryColor,
|
color: AppTheme.lightPrimaryColor,
|
||||||
),
|
),
|
||||||
SizedBox(width: 10.adaptedPx()),
|
SizedBox(width: 5.adaptedPx()),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
me.user.user.email,
|
me.user.email,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
|
@ -164,7 +163,6 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var lang =
|
var lang =
|
||||||
await languagePicker(context, settings.currentLanguage);
|
await languagePicker(context, settings.currentLanguage);
|
||||||
|
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
await settings.setLanguage(lang);
|
await settings.setLanguage(lang);
|
||||||
Navigator.of(context, rootNavigator: true)
|
Navigator.of(context, rootNavigator: true)
|
||||||
|
|
@ -198,7 +196,8 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
.bodyMedium
|
.bodyMedium
|
||||||
?.copyWith(
|
?.copyWith(
|
||||||
color: AppTheme.blackColor,
|
color: AppTheme.blackColor,
|
||||||
fontSize: 17.adaptedPx(),
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 15.adaptedPx(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -211,7 +210,7 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
itemCount: icons.length,
|
itemCount: icons.length,
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
separatorBuilder: (context, index) =>
|
separatorBuilder: (context, index) =>
|
||||||
SizedBox(height: 10.adaptedPx()),
|
SizedBox(height: 8.adaptedPx()),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return TextButton(
|
return TextButton(
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
|
@ -251,7 +250,7 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 30.adaptedPx()),
|
SizedBox(height: 15.adaptedPx()),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
launchUrlString('tel://+99363508564');
|
launchUrlString('tel://+99363508564');
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import 'package:carousel_slider/carousel_slider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:sapaly_shop/constants/utils.dart';
|
import 'package:sapaly_shop/constants/utils.dart';
|
||||||
import 'package:sapaly_shop/models/settings_model.dart';
|
import 'package:sapaly_shop/models/settings_model.dart';
|
||||||
import 'package:sapaly_shop/models/sliders_model.dart';
|
import 'package:sapaly_shop/models/sliders_model.dart';
|
||||||
|
|
@ -13,6 +14,7 @@ import 'package:sapaly_shop/features/screens/drawer/sapaly_drawer.dart';
|
||||||
import 'package:sapaly_shop/features/screens/home/product.dart';
|
import 'package:sapaly_shop/features/screens/home/product.dart';
|
||||||
import 'package:sapaly_shop/features/screens/home/search.dart';
|
import 'package:sapaly_shop/features/screens/home/search.dart';
|
||||||
import 'package:sapaly_shop/features/services/requests.dart';
|
import 'package:sapaly_shop/features/services/requests.dart';
|
||||||
|
import 'package:sapaly_shop/providers/user_provider.dart';
|
||||||
|
|
||||||
import '../../widgets/sapaly_app_bar.dart';
|
import '../../widgets/sapaly_app_bar.dart';
|
||||||
import '../../../constants/global_variables.dart';
|
import '../../../constants/global_variables.dart';
|
||||||
|
|
@ -73,7 +75,6 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||||
void initState() {
|
void initState() {
|
||||||
getSliders();
|
getSliders();
|
||||||
getSubCategories();
|
getSubCategories();
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +83,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppTheme.lightBackgroundColor,
|
backgroundColor: AppTheme.lightBackgroundColor,
|
||||||
key: _key,
|
key: _key,
|
||||||
drawer: SapalyDrawer(),
|
drawer: const SapalyDrawer(),
|
||||||
appBar: SapalyAppBar(
|
appBar: SapalyAppBar(
|
||||||
hasActionButton: true,
|
hasActionButton: true,
|
||||||
title: '',
|
title: '',
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,21 @@ class AuthService {
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse('${GlobalVariables.kBaseUrl}/jwt/login'),
|
Uri.parse('${GlobalVariables.kBaseUrl}/jwt/login'),
|
||||||
body: loginRequestModel.toMap(),
|
body: loginRequestModel.toJson(),
|
||||||
headers: {
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode == HttpStatus.ok) {
|
|
||||||
var data = response.body;
|
|
||||||
var loginResponse = LoginResponseModel.fromJson(data);
|
|
||||||
debugPrint('LOGIN ${loginResponse.user.email}');
|
|
||||||
}
|
|
||||||
|
|
||||||
httpErrorHandle(
|
httpErrorHandle(
|
||||||
response: response,
|
response: response,
|
||||||
context: context,
|
context: context,
|
||||||
onSuccess: () async {
|
onSuccess: () async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
Future.delayed(
|
||||||
|
const Duration(seconds: 3),
|
||||||
|
() async {
|
||||||
Provider.of<UserProvider>(context, listen: false)
|
Provider.of<UserProvider>(context, listen: false)
|
||||||
.setUser(response.body);
|
.setUser(response.body);
|
||||||
await prefs.setString(
|
await prefs.setString(
|
||||||
|
|
@ -51,6 +50,7 @@ class AuthService {
|
||||||
HomeScreen.routeName,
|
HomeScreen.routeName,
|
||||||
(route) => false,
|
(route) => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
context,
|
context,
|
||||||
content: 'login_success'.translation,
|
content: 'login_success'.translation,
|
||||||
|
|
@ -59,6 +59,8 @@ class AuthService {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
context,
|
context,
|
||||||
|
|
@ -120,18 +122,20 @@ class AuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get user data
|
// get user data
|
||||||
Future<void> getUserData({
|
Future<String> getUserData(BuildContext context) async {
|
||||||
required BuildContext context,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
|
var user = Provider.of<UserProvider>(context, listen: false).user;
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
String? token = prefs.getString('token');
|
String? token = prefs.getString('token');
|
||||||
|
user.token = token!;
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
prefs.setString('token', '');
|
prefs.setString('token', '');
|
||||||
}
|
}
|
||||||
|
return user.token;
|
||||||
// await http.post(Uri.parse('$uri'));
|
} catch (e) {
|
||||||
} catch (e) {}
|
debugPrint(e.toString());
|
||||||
|
return e.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send message
|
// send message
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ import 'package:sapaly_shop/models/settings_model.dart';
|
||||||
import 'package:sapaly_shop/themes/app_theme.dart';
|
import 'package:sapaly_shop/themes/app_theme.dart';
|
||||||
|
|
||||||
import '../screens/auth/login/login_screen.dart';
|
import '../screens/auth/login/login_screen.dart';
|
||||||
import '../screens/drawer/sapaly_drawer.dart';
|
|
||||||
import 'button.dart';
|
|
||||||
|
|
||||||
class UnAuthenticated extends StatefulWidget {
|
class UnAuthenticated extends StatefulWidget {
|
||||||
const UnAuthenticated({Key? key}) : super(key: key);
|
const UnAuthenticated({Key? key}) : super(key: key);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import 'package:sapaly_shop/features/screens/home/home_screen.dart';
|
||||||
import 'package:sapaly_shop/features/screens/auth/login/login_screen.dart';
|
import 'package:sapaly_shop/features/screens/auth/login/login_screen.dart';
|
||||||
import 'package:sapaly_shop/features/screens/home/onboarding.dart';
|
import 'package:sapaly_shop/features/screens/home/onboarding.dart';
|
||||||
import 'package:sapaly_shop/features/screens/settings/settings_screen.dart';
|
import 'package:sapaly_shop/features/screens/settings/settings_screen.dart';
|
||||||
import 'package:sapaly_shop/features/services/auth_service.dart';
|
|
||||||
import 'package:sapaly_shop/providers/user_provider.dart';
|
import 'package:sapaly_shop/providers/user_provider.dart';
|
||||||
import 'package:sapaly_shop/router.dart';
|
import 'package:sapaly_shop/router.dart';
|
||||||
import 'package:sapaly_shop/themes/app_theme.dart';
|
import 'package:sapaly_shop/themes/app_theme.dart';
|
||||||
|
|
@ -20,17 +19,18 @@ import 'models/settings_model.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
||||||
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
|
||||||
Future.delayed(const Duration(seconds: 5));
|
|
||||||
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
||||||
|
Future.delayed(const Duration(seconds: 4));
|
||||||
|
|
||||||
await SettingsModel.initLocalization(
|
await SettingsModel.initLocalization(
|
||||||
prefs.getString('language') ?? kDefaultLanguage);
|
prefs.getString('language') ?? kDefaultLanguage);
|
||||||
runApp(
|
runApp(
|
||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider(create: (_) => SettingsModel(prefs)),
|
|
||||||
ChangeNotifierProvider(create: (_) => UserProvider()),
|
ChangeNotifierProvider(create: (_) => UserProvider()),
|
||||||
|
ChangeNotifierProvider(create: (_) => SettingsModel(prefs)),
|
||||||
],
|
],
|
||||||
child: const MyApp(),
|
child: const MyApp(),
|
||||||
),
|
),
|
||||||
|
|
@ -38,16 +38,9 @@ Future<void> main() async {
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyApp> createState() => _MyAppState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
|
||||||
final AuthService service = AuthService();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizeInitializer(
|
return SizeInitializer(
|
||||||
|
|
@ -60,7 +53,7 @@ class _MyAppState extends State<MyApp> {
|
||||||
onGenerateRoute: (settings) => generateRoute(settings),
|
onGenerateRoute: (settings) => generateRoute(settings),
|
||||||
routes: <String, WidgetBuilder>{
|
routes: <String, WidgetBuilder>{
|
||||||
'/onboarding': (context) => const Onboarding(),
|
'/onboarding': (context) => const Onboarding(),
|
||||||
'/drawer': (context) => SapalyDrawer(),
|
'/drawer': (context) => const SapalyDrawer(),
|
||||||
'/home': (context) => const HomeScreen(),
|
'/home': (context) => const HomeScreen(),
|
||||||
'/category': (context) => const CategoryScreen(),
|
'/category': (context) => const CategoryScreen(),
|
||||||
'/login': (context) => const LoginScreen(),
|
'/login': (context) => const LoginScreen(),
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class LoginRequestModel {
|
class LoginRequestModel {
|
||||||
final String email;
|
String email;
|
||||||
final String password;
|
String password;
|
||||||
LoginRequestModel({
|
LoginRequestModel({
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.password,
|
required this.password,
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,16 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
// To parse this JSON data, do
|
|
||||||
//
|
|
||||||
// final userResponseModel = userResponseModelFromJson(jsonString);
|
|
||||||
|
|
||||||
class LoginResponseModel {
|
class LoginResponseModel {
|
||||||
final String token;
|
String token;
|
||||||
final String expires;
|
User user;
|
||||||
final User user;
|
|
||||||
LoginResponseModel({
|
LoginResponseModel({
|
||||||
required this.token,
|
required this.token,
|
||||||
required this.expires,
|
|
||||||
required this.user,
|
required this.user,
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
'token': token,
|
'token': token,
|
||||||
'expires': expires,
|
|
||||||
'user': user.toMap(),
|
'user': user.toMap(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -27,8 +18,10 @@ class LoginResponseModel {
|
||||||
factory LoginResponseModel.fromMap(Map<String, dynamic> map) {
|
factory LoginResponseModel.fromMap(Map<String, dynamic> map) {
|
||||||
return LoginResponseModel(
|
return LoginResponseModel(
|
||||||
token: map['data']['token'] ?? '',
|
token: map['data']['token'] ?? '',
|
||||||
expires: map['data']['expires'] ?? '',
|
// user: User.fromMap(map['data']['user'] ?? ''),
|
||||||
user: User.fromMap(map['data']['user']),
|
user: (map['data']["user"] != null)
|
||||||
|
? User.fromMap(map['data']["user"])
|
||||||
|
: null!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,29 +36,13 @@ class User {
|
||||||
final String email;
|
final String email;
|
||||||
final String name;
|
final String name;
|
||||||
final String lastName;
|
final String lastName;
|
||||||
final String middleName;
|
|
||||||
final String phone;
|
final String phone;
|
||||||
final String phoneShort;
|
|
||||||
final bool isActivated;
|
|
||||||
final String lastLogin;
|
|
||||||
final int isSuperuser;
|
|
||||||
final String createdAt;
|
|
||||||
final String updatedAt;
|
|
||||||
final List<String> phoneList;
|
|
||||||
User({
|
User({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.lastName,
|
required this.lastName,
|
||||||
required this.middleName,
|
|
||||||
required this.phone,
|
required this.phone,
|
||||||
required this.phoneShort,
|
|
||||||
required this.isActivated,
|
|
||||||
required this.lastLogin,
|
|
||||||
required this.isSuperuser,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.phoneList,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
|
|
@ -73,16 +50,8 @@ class User {
|
||||||
'id': id,
|
'id': id,
|
||||||
'email': email,
|
'email': email,
|
||||||
'name': name,
|
'name': name,
|
||||||
'lastName': lastName,
|
'last_name': lastName,
|
||||||
'middleName': middleName,
|
|
||||||
'phone': phone,
|
'phone': phone,
|
||||||
'phoneShort': phoneShort,
|
|
||||||
'isActivated': isActivated,
|
|
||||||
'lastLogin': lastLogin,
|
|
||||||
'isSuperuser': isSuperuser,
|
|
||||||
'createdAt': createdAt,
|
|
||||||
'updatedAt': updatedAt,
|
|
||||||
'phone_list': phoneList,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,16 +60,8 @@ class User {
|
||||||
id: map['id'] ?? 0,
|
id: map['id'] ?? 0,
|
||||||
email: map['email'] ?? '',
|
email: map['email'] ?? '',
|
||||||
name: map['name'] ?? '',
|
name: map['name'] ?? '',
|
||||||
lastName: map['lastName'] ?? '',
|
lastName: map['last_name'] ?? '',
|
||||||
middleName: map['middleName'] ?? '',
|
|
||||||
phone: map['phone'] ?? '',
|
phone: map['phone'] ?? '',
|
||||||
phoneShort: map['phoneShort'] ?? '',
|
|
||||||
isActivated: map['isActivated'] ?? false,
|
|
||||||
lastLogin: map['lastLogin'] ?? '',
|
|
||||||
isSuperuser: map['isSuperuser'] ?? 0,
|
|
||||||
createdAt: map['createdAt'] ?? '',
|
|
||||||
updatedAt: map['updatedAt'] ?? '',
|
|
||||||
phoneList: List<String>.from(map['phone_list']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
RegisterResponseModel registerResponseModelFromJson(String str) =>
|
RegisterResponseModel registerResponseModelFromJson(String str) =>
|
||||||
RegisterResponseModel.fromJson(json.decode(str));
|
RegisterResponseModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
|
@ -27,7 +25,9 @@ class RegisterResponseModel {
|
||||||
RegisterResponseModel(
|
RegisterResponseModel(
|
||||||
token: json['data']["token"],
|
token: json['data']["token"],
|
||||||
expires: DateTime.parse(json['data']["expires"]),
|
expires: DateTime.parse(json['data']["expires"]),
|
||||||
user: User.fromJson(json['data']["user"]),
|
user: (json['data']["user"] != null)
|
||||||
|
? User.fromMap(json['data']["user"])
|
||||||
|
: null!,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
|
|
@ -42,29 +42,13 @@ class User {
|
||||||
final String email;
|
final String email;
|
||||||
final String name;
|
final String name;
|
||||||
final String lastName;
|
final String lastName;
|
||||||
final String middleName;
|
|
||||||
final String phone;
|
final String phone;
|
||||||
final String phoneShort;
|
|
||||||
final bool isActivated;
|
|
||||||
final DateTime lastLogin;
|
|
||||||
final int isSuperuser;
|
|
||||||
final DateTime createdAt;
|
|
||||||
final DateTime updatedAt;
|
|
||||||
final List<String> phoneList;
|
|
||||||
User({
|
User({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.lastName,
|
required this.lastName,
|
||||||
required this.middleName,
|
|
||||||
required this.phone,
|
required this.phone,
|
||||||
required this.phoneShort,
|
|
||||||
required this.isActivated,
|
|
||||||
required this.lastLogin,
|
|
||||||
required this.isSuperuser,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.phoneList,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
|
|
@ -72,16 +56,8 @@ class User {
|
||||||
'id': id,
|
'id': id,
|
||||||
'email': email,
|
'email': email,
|
||||||
'name': name,
|
'name': name,
|
||||||
'lastName': lastName,
|
'last_name': lastName,
|
||||||
'middleName': middleName,
|
|
||||||
'phone': phone,
|
'phone': phone,
|
||||||
'phoneShort': phoneShort,
|
|
||||||
'isActivated': isActivated,
|
|
||||||
'lastLogin': lastLogin.millisecondsSinceEpoch,
|
|
||||||
'isSuperuser': isSuperuser,
|
|
||||||
'createdAt': createdAt.millisecondsSinceEpoch,
|
|
||||||
'updatedAt': updatedAt.millisecondsSinceEpoch,
|
|
||||||
'phone_list': phoneList,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,16 +66,8 @@ class User {
|
||||||
id: map['id']?.toInt() ?? 0,
|
id: map['id']?.toInt() ?? 0,
|
||||||
email: map['email'] ?? '',
|
email: map['email'] ?? '',
|
||||||
name: map['name'] ?? '',
|
name: map['name'] ?? '',
|
||||||
lastName: map['lastName'] ?? '',
|
lastName: map['last_name'] ?? '',
|
||||||
middleName: map['middleName'] ?? '',
|
|
||||||
phone: map['phone'] ?? '',
|
phone: map['phone'] ?? '',
|
||||||
phoneShort: map['phoneShort'] ?? '',
|
|
||||||
isActivated: map['isActivated'] ?? false,
|
|
||||||
lastLogin: DateTime.fromMillisecondsSinceEpoch(map['lastLogin']),
|
|
||||||
isSuperuser: map['isSuperuser']?.toInt() ?? 0,
|
|
||||||
createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']),
|
|
||||||
updatedAt: DateTime.fromMillisecondsSinceEpoch(map['updatedAt']),
|
|
||||||
phoneList: List<String>.from(map['phone_list']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,19 @@ import 'package:sapaly_shop/models/auth/login/login_response_model.dart';
|
||||||
class UserProvider extends ChangeNotifier {
|
class UserProvider extends ChangeNotifier {
|
||||||
LoginResponseModel _user = LoginResponseModel(
|
LoginResponseModel _user = LoginResponseModel(
|
||||||
token: '',
|
token: '',
|
||||||
expires: '',
|
|
||||||
user: User(
|
user: User(
|
||||||
id: 0,
|
id: 0,
|
||||||
email: '',
|
email: '',
|
||||||
name: '',
|
name: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
middleName: '',
|
|
||||||
phone: '',
|
phone: '',
|
||||||
phoneShort: '',
|
|
||||||
isActivated: true,
|
|
||||||
lastLogin: '',
|
|
||||||
isSuperuser: 0,
|
|
||||||
createdAt: '',
|
|
||||||
updatedAt: '',
|
|
||||||
phoneList: [],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
LoginResponseModel get user => _user;
|
LoginResponseModel get user => _user;
|
||||||
|
|
||||||
void setUser(String user) {
|
void setUser(String user) {
|
||||||
_user = LoginResponseModel.fromJson(user);
|
_user = LoginResponseModel.fromJson(user);
|
||||||
|
debugPrint(user);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,23 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sapaly_shop/features/screens/home/home_screen.dart';
|
|
||||||
|
|
||||||
import 'features/screens/auth/login/login_screen.dart';
|
import 'features/screens/auth/login/login_screen.dart';
|
||||||
import 'features/screens/home/onboarding.dart';
|
import 'features/screens/home/onboarding.dart';
|
||||||
|
|
||||||
Route<dynamic> generateRoute(RouteSettings routeSettings) {
|
Route<dynamic> generateRoute(RouteSettings routeSettings) {
|
||||||
switch (routeSettings.name) {
|
switch (routeSettings.name) {
|
||||||
case HomeScreen.routeName:
|
case Onboarding.routeName:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => const HomeScreen(),
|
builder: (context) => const Onboarding(),
|
||||||
);
|
);
|
||||||
case LoginScreen.routeName:
|
case LoginScreen.routeName:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => const LoginScreen(),
|
builder: (_) => const LoginScreen(),
|
||||||
);
|
);
|
||||||
case Onboarding.routeName:
|
|
||||||
return MaterialPageRoute(
|
|
||||||
builder: (context) => const Onboarding(),
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
settings: routeSettings,
|
settings: routeSettings,
|
||||||
builder: (_) => const HomeScreen(),
|
builder: (_) => const Onboarding(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
pubspec.lock
18
pubspec.lock
|
|
@ -248,10 +248,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_svg
|
name: flutter_svg
|
||||||
sha256: "017cb37b3e9bee44cc800e35469f295d537484602f02ce6ceb5876236cc7e1fe"
|
sha256: "12006889e2987c549c4c1ec1a5ba4ec4b24d34d2469ee5f9476c926dcecff266"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.4"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
@ -759,26 +759,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics
|
name: vector_graphics
|
||||||
sha256: "2f317d969a9f1eb59d1890643107da749698b7c08c4b0532fc95c8a7130d2803"
|
sha256: "4cf8e60dbe4d3a693d37dff11255a172594c0793da542183cbfe7fe978ae4aaa"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.4"
|
||||||
vector_graphics_codec:
|
vector_graphics_codec:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_codec
|
name: vector_graphics_codec
|
||||||
sha256: "13cccfda2dd61232a19dfb769b7a907e2ab23aabfebb9053c81e29c6c11b1766"
|
sha256: "278ad5f816f58b1967396d1f78ced470e3e58c9fe4b27010102c0a595c764468"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.4"
|
||||||
vector_graphics_compiler:
|
vector_graphics_compiler:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_compiler
|
name: vector_graphics_compiler
|
||||||
sha256: "524c9889a1327401124fe068840a8867f0d57987c1219a2a696ade629ec2bec3"
|
sha256: "0bf61ad56e6fd6688a2865d3ceaea396bc6a0a90ea0d7ad5049b1b76c09d6163"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.4"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -820,5 +820,5 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.1"
|
version: "3.1.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.19.0 <3.0.0"
|
dart: ">=2.19.2 <3.0.0"
|
||||||
flutter: ">=3.7.0-0"
|
flutter: ">=3.7.0-0"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.19.0 <3.0.0'
|
sdk: '>=2.19.2 <3.0.0'
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
# Dependencies specify other packages that your package needs in order to work.
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
# To automatically upgrade your package dependencies to the latest versions
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue