major bug fix, unauhenticaed widget added
This commit is contained in:
parent
e52b41dc8b
commit
82f1265997
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 6.2 KiB |
|
|
@ -230,6 +230,7 @@ class _DetailsState extends State<Details> {
|
|||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.adaptedPx()),
|
||||
InkWell(
|
||||
splashColor: AppTheme.lightPrimaryColor.withOpacity(0.2),
|
||||
highlightColor:
|
||||
|
|
@ -253,38 +254,33 @@ class _DetailsState extends State<Details> {
|
|||
),
|
||||
);
|
||||
},
|
||||
child: CustomButton(
|
||||
name: 'add_to_cart'.translation,
|
||||
onTap: () {},
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
isMain: true,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1.adaptedPx(),
|
||||
color: AppTheme.lightPrimaryColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(15.adaptedPx()),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 15.adaptedPx(),
|
||||
horizontal: 15.adaptedPx(),
|
||||
),
|
||||
child: Text(
|
||||
'add_to_cart'.translation,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
fontSize: 15.adaptedPx(),
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.lightPrimaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Container(
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// width: 1.adaptedPx(),
|
||||
// color: AppTheme.lightPrimaryColor,
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(15.adaptedPx()),
|
||||
// ),
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// vertical: 15.adaptedPx(),
|
||||
// horizontal: 15.adaptedPx(),
|
||||
// ),
|
||||
// child: Text(
|
||||
// 'add_to_cart'.translation,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: Theme.of(context)
|
||||
// .primaryTextTheme
|
||||
// .bodyMedium
|
||||
// ?.copyWith(
|
||||
// fontSize: 15.adaptedPx(),
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: AppTheme.lightPrimaryColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
SizedBox(height: 15.adaptedPx()),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -3,14 +3,20 @@
|
|||
import 'package:adaptix/adaptix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sapaly_shop/common/custom_button.dart';
|
||||
import 'package:sapaly_shop/common/widgets/custom_text_field.dart';
|
||||
import 'package:sapaly_shop/constants/global_variables.dart';
|
||||
import 'package:sapaly_shop/features/screens/drawer/sapaly_drawer.dart';
|
||||
import 'package:sapaly_shop/features/screens/home/home_screen.dart';
|
||||
import 'package:sapaly_shop/features/services/auth_service.dart';
|
||||
import 'package:sapaly_shop/features/widgets/sapaly_app_bar.dart';
|
||||
import 'package:sapaly_shop/features/widgets/unauthenticatedWidget.dart';
|
||||
import 'package:sapaly_shop/models/settings_model.dart';
|
||||
import 'package:sapaly_shop/providers/user_provider.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../../../models/auth/login/login_request_model.dart';
|
||||
import '../../../themes/app_theme.dart';
|
||||
|
||||
class ContactsScreen extends StatefulWidget {
|
||||
|
|
@ -26,14 +32,27 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
|||
TextEditingController subjectController = TextEditingController();
|
||||
TextEditingController messageController = TextEditingController();
|
||||
final GlobalKey<ScaffoldState> _key = GlobalKey();
|
||||
final AuthService authService = AuthService();
|
||||
|
||||
String number1 = '+993 63721584';
|
||||
String number2 = '25-53-19';
|
||||
String mail1 = 'enquery@gmail.com';
|
||||
String mail2 = 'help@yourdomain.com';
|
||||
|
||||
void sendMessage() {
|
||||
debugPrint('EMAIL ${emailController.text}');
|
||||
authService.sendMessage(
|
||||
loginRequestModel: LoginRequestModel(
|
||||
email: emailController.text,
|
||||
password: messageController.text,
|
||||
),
|
||||
context: context,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var me = Provider.of<UserProvider>(context, listen: false);
|
||||
return Scaffold(
|
||||
drawer: SapalyDrawer(),
|
||||
backgroundColor: AppTheme.lightBackgroundColor,
|
||||
|
|
@ -78,7 +97,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
|||
contentPadding: 0,
|
||||
),
|
||||
CustomTextField(
|
||||
labelText: 'subject',
|
||||
labelText: 'subject'.translation,
|
||||
hintText: 'subject'.translation,
|
||||
controller: subjectController,
|
||||
obscureText: false,
|
||||
|
|
@ -100,7 +119,15 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
|||
),
|
||||
CustomButton(
|
||||
name: 'send_message'.translation,
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => me.user.token.isEmpty
|
||||
? const UnAuthenticated()
|
||||
: const HomeScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
isMain: true,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@ import 'package:sapaly_shop/features/screens/drawer/sales.dart';
|
|||
import 'package:sapaly_shop/features/screens/drawer/shops.dart';
|
||||
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/services/page_navigator.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/settings_model.dart';
|
||||
import 'package:sapaly_shop/providers/user_provider.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../../../constants/global_variables.dart';
|
||||
|
|
@ -85,7 +87,8 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SettingsModel settings = Provider.of<SettingsModel>(context, listen: true);
|
||||
var settings = Provider.of<SettingsModel>(context, listen: false);
|
||||
var me = Provider.of<UserProvider>(context, listen: false);
|
||||
return Drawer(
|
||||
backgroundColor: AppTheme.whiteColor,
|
||||
child: Padding(
|
||||
|
|
@ -118,26 +121,43 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
|||
],
|
||||
),
|
||||
),
|
||||
me.user.user.email == '' && me.user.user.name == ''
|
||||
? Container()
|
||||
: GestureDetector(
|
||||
onTap: () {
|
||||
PageNavigator(ctx: context)
|
||||
.nextPage(page: const SettingsScreen());
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.account_circle,
|
||||
size: 35.adaptedPx(),
|
||||
color: AppTheme.lightPrimaryColor,
|
||||
),
|
||||
SizedBox(width: 10.adaptedPx()),
|
||||
Expanded(
|
||||
child: Text(
|
||||
me.user.user.email.isEmpty
|
||||
? me.user.user.email
|
||||
: me.user.user.name,
|
||||
softWrap: true,
|
||||
maxLines: 4,
|
||||
style: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.blackColor,
|
||||
fontSize: 13.adaptedPx(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.account_circle,
|
||||
size: 35.adaptedPx(),
|
||||
color: AppTheme.lightPrimaryColor,
|
||||
),
|
||||
SizedBox(width: 10.adaptedPx()),
|
||||
Text(
|
||||
'Aman Amanow',
|
||||
softWrap: true,
|
||||
maxLines: 2,
|
||||
style:
|
||||
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.blackColor,
|
||||
fontSize: 13.adaptedPx(),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
SapalyIcon(
|
||||
onTap: () async {
|
||||
var lang =
|
||||
|
|
@ -149,21 +169,18 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
|||
.pushNamedAndRemoveUntil('/home', (route) => false);
|
||||
}
|
||||
},
|
||||
width: 22.adaptedPx(),
|
||||
height: 22.adaptedPx(),
|
||||
width: 25.adaptedPx(),
|
||||
height: 25.adaptedPx(),
|
||||
hasBadge: false,
|
||||
child: SvgPicture.asset('assets/icons/lang.svg'),
|
||||
),
|
||||
SizedBox(width: 10.adaptedPx()),
|
||||
Text(
|
||||
settings.currentLanguage == 'tk'
|
||||
? 'TM'
|
||||
: settings.currentLanguage.toUpperCase(),
|
||||
'currentLang'.translation,
|
||||
style:
|
||||
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.blackColor,
|
||||
fontSize: 13.adaptedPx(),
|
||||
fontSize: 15.adaptedPx(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -177,7 +194,7 @@ class _SapalyDrawerState extends State<SapalyDrawer> {
|
|||
return TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: GlobalVariables.verticalPadding(context) / 2,
|
||||
vertical: GlobalVariables.verticalPadding(context) / 3,
|
||||
horizontal:
|
||||
GlobalVariables.horizontalPadding(context) / 2,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -24,20 +24,17 @@ class _ProfileScreenState extends State<SettingsScreen> {
|
|||
Widget build(BuildContext context) {
|
||||
var me = Provider.of<UserProvider>(context, listen: false);
|
||||
SettingsModel settings = Provider.of<SettingsModel>(context, listen: true);
|
||||
final GlobalKey<ScaffoldState> _key = GlobalKey();
|
||||
String email = 'demir.at@gmail.com';
|
||||
return Scaffold(
|
||||
drawer: SapalyDrawer(),
|
||||
backgroundColor: AppTheme.lightBackgroundColor,
|
||||
key: _key,
|
||||
appBar: SapalyAppBar(
|
||||
hasActionButton: true,
|
||||
title: 'settings'.translation,
|
||||
badge: '2',
|
||||
leadingButton: SvgPicture.asset('assets/icons/menu.svg'),
|
||||
leadingButton: const Icon(Icons.arrow_back),
|
||||
actionButton: SvgPicture.asset('assets/icons/cart.svg'),
|
||||
leadingOnTap: () {
|
||||
_key.currentState?.openDrawer();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
actionOnTap: () {},
|
||||
),
|
||||
|
|
@ -91,6 +88,7 @@ class _ProfileScreenState extends State<SettingsScreen> {
|
|||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.adaptedPx()),
|
||||
Text(
|
||||
me.user.user.name,
|
||||
style: Theme.of(context)
|
||||
|
|
@ -117,6 +115,7 @@ class _ProfileScreenState extends State<SettingsScreen> {
|
|||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.adaptedPx()),
|
||||
Text(
|
||||
me.user.user.phone,
|
||||
style: Theme.of(context)
|
||||
|
|
@ -125,6 +124,7 @@ class _ProfileScreenState extends State<SettingsScreen> {
|
|||
?.copyWith(
|
||||
fontSize: 13.adaptedPx(),
|
||||
color: AppTheme.blackColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -132,4 +132,54 @@ class AuthService {
|
|||
// await http.post(Uri.parse('$uri'));
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// send message
|
||||
Future<void> sendMessage({
|
||||
required LoginRequestModel loginRequestModel,
|
||||
required BuildContext context,
|
||||
}) async {
|
||||
try {
|
||||
var response = await http.post(Uri.parse('$kBaseUrl/jwt/contact'),
|
||||
body: loginRequestModel.toMap(),
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
var data = response.body;
|
||||
var loginResponse = LoginResponseModel.fromJson(data);
|
||||
debugPrint('LOGIN ${loginResponse.user.email}');
|
||||
}
|
||||
|
||||
httpErrorHandle(
|
||||
response: response,
|
||||
context: context,
|
||||
onSuccess: () async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
Provider.of<UserProvider>(context, listen: false)
|
||||
.setUser(response.body);
|
||||
await prefs.setString(
|
||||
'token', jsonDecode(response.body)['data']['token']);
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeScreen.routeName,
|
||||
(route) => false,
|
||||
);
|
||||
showSnackBar(
|
||||
context,
|
||||
content: 'login_success'.translation,
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
textColor: AppTheme.whiteColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
showSnackBar(
|
||||
context,
|
||||
content: e.toString(),
|
||||
backgroundColor: AppTheme.redColor,
|
||||
textColor: AppTheme.whiteColor,
|
||||
);
|
||||
debugPrint('Login ERROR ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:adaptix/adaptix.dart';
|
||||
import 'package:sapaly_shop/common/custom_button.dart';
|
||||
import 'package:sapaly_shop/features/services/page_navigator.dart';
|
||||
import 'package:sapaly_shop/features/widgets/sapaly_app_bar.dart';
|
||||
import 'package:sapaly_shop/models/settings_model.dart';
|
||||
import 'package:sapaly_shop/themes/app_theme.dart';
|
||||
|
||||
import '../screens/auth/login/login_screen.dart';
|
||||
import '../screens/drawer/sapaly_drawer.dart';
|
||||
import 'button.dart';
|
||||
|
||||
class UnAuthenticated extends StatefulWidget {
|
||||
const UnAuthenticated({Key? key}) : super(key: key);
|
||||
@override
|
||||
_UnAuthenticatedState createState() => _UnAuthenticatedState();
|
||||
}
|
||||
|
||||
class _UnAuthenticatedState extends State<UnAuthenticated> {
|
||||
final GlobalKey<ScaffoldState> _key = GlobalKey();
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _key,
|
||||
backgroundColor: AppTheme.lightBackgroundColor,
|
||||
appBar: SapalyAppBar(
|
||||
hasActionButton: false,
|
||||
title: '',
|
||||
badge: '',
|
||||
leadingButton: const Icon(Icons.arrow_back),
|
||||
actionButton: Container(),
|
||||
leadingOnTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
actionOnTap: () {},
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
width: 60.orientationWidth,
|
||||
height: 200.adaptedPx(),
|
||||
child: SvgPicture.asset('assets/images/unauth.svg'),
|
||||
),
|
||||
Text(
|
||||
'needToEnter'.translation,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
|
||||
color: AppTheme.lightPrimaryColor,
|
||||
fontSize: 15.adaptedPx(),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.adaptedPx(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 100.adaptedPx()),
|
||||
child: CustomButton(
|
||||
name: 'login'.translation,
|
||||
onTap: () {
|
||||
PageNavigator(ctx: context)
|
||||
.nextPage(page: const LoginScreen());
|
||||
},
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
isMain: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
"repeat_password":"Repeat password",
|
||||
"repeat_password_to_confirm":"Repeat password to confirm",
|
||||
"add_to_cart":"Add to cart",
|
||||
"added_to_cart":"Added to cart",
|
||||
"home":"Home",
|
||||
"about_us":"About us",
|
||||
"sales":"Sales",
|
||||
|
|
@ -22,7 +23,13 @@
|
|||
"settings":"Settings",
|
||||
"currentLang":"Language",
|
||||
"our_location":"Our location",
|
||||
"login_success":"Successfully logged in!"
|
||||
|
||||
|
||||
"login_success":"Successfully logged in!",
|
||||
"send_message":"Send message",
|
||||
"first_name":"First name",
|
||||
"subject":"Subject of message",
|
||||
"message":"Your message...",
|
||||
"needToEnter":"Log in to use the service",
|
||||
"error_occured":"Error occured",
|
||||
"info_about_user":"Information about user",
|
||||
"edit":"Edit"
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
"repeat_password":"Повторите пароль",
|
||||
"repeat_password_to_confirm":"Повторите пароль для подтверждения",
|
||||
"add_to_cart":"Добавить в корзину",
|
||||
"added_to_cart":"Добавлено в корзину",
|
||||
"home":"Главная",
|
||||
"about_us":"О нас",
|
||||
"sales":"Продажи",
|
||||
|
|
@ -22,6 +23,14 @@
|
|||
"settings":"Настройки",
|
||||
"currentLang":"Язык",
|
||||
"our_location":"Наш адрес",
|
||||
"login_success":"Успешно авторизовано!"
|
||||
"login_success":"Успешно авторизовано!",
|
||||
"send_message":"Отправить сообщение",
|
||||
"first_name":"Ваше имя",
|
||||
"subject":"Тема сообщения",
|
||||
"message":"Ваше сообщение...",
|
||||
"needToEnter":"Чтобы воспользоваться услугой авторизуйтесь",
|
||||
"error_occured":"Произошла ошибка",
|
||||
"info_about_user":"Информация о пользователе",
|
||||
"edit":"Редактировать"
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
"repeat_password":"Açar sözi gaýtalaň",
|
||||
"repeat_password_to_confirm":"Açar sözi tassyklamak üçin gaýtalaň",
|
||||
"add_to_cart":"Sebede goş",
|
||||
"added_to_cart":"Sebede goşuldy",
|
||||
"home":"Esasy sahypa",
|
||||
"about_us":"Biz barada",
|
||||
"sales":"Satuwlar",
|
||||
|
|
@ -22,5 +23,13 @@
|
|||
"settings":"Sazlamalar",
|
||||
"currentLang":"Dili saýlaň",
|
||||
"our_location":"Biziň salgymyz",
|
||||
"login_success":"Üstünlikli içeri girdiňiz!"
|
||||
"login_success":"Üstünlikli içeri girdiňiz!",
|
||||
"send_message":"Ugratmak",
|
||||
"first_name":"Ady",
|
||||
"subject":"Hatyň mowzugy",
|
||||
"message":"Siziň hatyňyz...",
|
||||
"needToEnter":"Hyzmaty ulanmak üçin ulgama giriň",
|
||||
"error_occured":"Näsazlyk ýüze çykdy",
|
||||
"info_about_user":"Ulanyjy barada maglumat",
|
||||
"edit":"Üýtgetmek"
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ extension LocalMessageExt on String {
|
|||
"repeat_password_to_confirm":
|
||||
SettingsModel._localization?.repeat_password_to_confirm,
|
||||
"add_to_cart": SettingsModel._localization?.add_to_cart,
|
||||
"added_to_cart": SettingsModel._localization?.added_to_cart,
|
||||
"home": SettingsModel._localization?.home,
|
||||
"about_us": SettingsModel._localization?.about_us,
|
||||
"sales": SettingsModel._localization?.sales,
|
||||
|
|
@ -84,6 +85,12 @@ extension LocalMessageExt on String {
|
|||
"currentLang": SettingsModel._localization?.currentLang,
|
||||
"our_location": SettingsModel._localization?.our_location,
|
||||
"login_success": SettingsModel._localization?.login_success,
|
||||
"send_message": SettingsModel._localization?.send_message,
|
||||
"first_name": SettingsModel._localization?.first_name,
|
||||
"subject": SettingsModel._localization?.subject,
|
||||
"message": SettingsModel._localization?.message,
|
||||
"needToEnter": SettingsModel._localization?.needToEnter,
|
||||
"info_about_user": SettingsModel._localization?.info_about_user,
|
||||
}[this] ??
|
||||
this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue