sapaly_store/lib/features/screens/settings/settings_screen.dart

336 lines
14 KiB
Dart

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/features/screens/drawer/sapaly_drawer.dart';
import 'package:sapaly_shop/features/widgets/sapaly_app_bar.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/modals.dart';
import '../../../themes/app_theme.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({super.key});
@override
State<SettingsScreen> createState() => _ProfileScreenState();
}
class _ProfileScreenState extends State<SettingsScreen> {
@override
Widget build(BuildContext context) {
var me = Provider.of<UserProvider>(context, listen: false);
SettingsModel settings = Provider.of<SettingsModel>(context, listen: true);
String email = 'demir.at@gmail.com';
return Scaffold(
backgroundColor: AppTheme.lightBackgroundColor,
appBar: SapalyAppBar(
hasActionButton: true,
title: 'settings'.translation,
badge: '2',
leadingButton: const Icon(Icons.arrow_back),
actionButton: SvgPicture.asset('assets/icons/cart.svg'),
leadingOnTap: () {
Navigator.pop(context);
},
actionOnTap: () {},
),
body: Container(
margin: EdgeInsets.symmetric(
vertical: 15.adaptedPx(),
horizontal: 15.adaptedPx(),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
me != null
? Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.adaptedPx(),
color: AppTheme.lightTextColor.withOpacity(0.3),
),
borderRadius: BorderRadius.circular(15.adaptedPx()),
),
padding: EdgeInsets.symmetric(
vertical: 15.adaptedPx(),
horizontal: 15.adaptedPx(),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'info_about_user'.translation,
textAlign: TextAlign.start,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
SizedBox(height: 15.adaptedPx()),
Row(
children: [
Text(
'name:'.translation,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.lightPrimaryColor,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 10.adaptedPx()),
Text(
me.user.user.name,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.blackColor,
),
),
],
),
SizedBox(height: 15.adaptedPx()),
Row(
children: [
Text(
'phone:'.translation,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.lightPrimaryColor,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 10.adaptedPx()),
Text(
me.user.user.phone,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.blackColor,
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 15.adaptedPx()),
CustomButton(
name: 'edit'.translation,
onTap: () {},
backgroundColor: AppTheme.lightPrimaryColor,
isMain: true,
),
],
),
)
: Container(),
InkWell(
splashColor: AppTheme.lightPrimaryColor.withOpacity(0.2),
highlightColor: AppTheme.lightPrimaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(15.adaptedPx()),
onTap: () async {
var lang =
await languagePicker(context, settings.currentLanguage);
if (lang != null) {
await settings.setLanguage(lang);
// ignore: use_build_context_synchronously
Navigator.of(context, rootNavigator: true)
.pushNamedAndRemoveUntil('/home', (route) => false);
}
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.adaptedPx(),
color: AppTheme.lightTextColor.withOpacity(0.3),
),
borderRadius: BorderRadius.circular(15.adaptedPx()),
),
padding: EdgeInsets.symmetric(
vertical: 15.adaptedPx(),
horizontal: 15.adaptedPx(),
),
child: Row(
children: [
SvgPicture.asset('assets/icons/lang.svg'),
SizedBox(width: 10.adaptedPx()),
Text(
'language'.translation,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
),
),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.adaptedPx(),
color: AppTheme.lightTextColor.withOpacity(0.3),
),
borderRadius: BorderRadius.circular(15.adaptedPx()),
),
padding: EdgeInsets.symmetric(
vertical: 15.adaptedPx(),
horizontal: 15.adaptedPx(),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
launchUrlString('tel://+99361445445');
},
child: Row(
children: [
const Icon(Icons.phone_outlined,
color: AppTheme.lightPrimaryColor),
SizedBox(width: 10.adaptedPx()),
Text(
'+993 61 445445',
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
),
SizedBox(height: 15.adaptedPx()),
GestureDetector(
onTap: () async {
if (await canLaunchUrlString("mailto:$email")) {
await launchUrlString("mailto:$email");
}
},
child: Row(
children: [
const Icon(Icons.mail_outline,
color: AppTheme.lightPrimaryColor),
SizedBox(width: 10.adaptedPx()),
Text(
'demir.at@gmail.com',
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
),
SizedBox(height: 15.adaptedPx()),
Row(
children: [
const Icon(Icons.map_outlined,
color: AppTheme.lightPrimaryColor),
SizedBox(width: 10.adaptedPx()),
Text(
'Ataturk 16 - 2',
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
SizedBox(height: 15.adaptedPx()),
Row(
children: [
const Icon(Icons.access_time_outlined,
color: AppTheme.lightPrimaryColor),
SizedBox(width: 10.adaptedPx()),
Text(
'8:00 - 18:00',
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
],
),
),
InkWell(
splashColor: AppTheme.lightPrimaryColor.withOpacity(0.2),
highlightColor: AppTheme.lightPrimaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(15.adaptedPx()),
onTap: () {},
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.adaptedPx(),
color: AppTheme.lightTextColor.withOpacity(0.3),
),
borderRadius: BorderRadius.circular(15.adaptedPx()),
),
padding: EdgeInsets.symmetric(
vertical: 15.adaptedPx(),
horizontal: 15.adaptedPx(),
),
child: Row(
children: [
const Icon(Icons.info_outline,
color: AppTheme.lightPrimaryColor),
SizedBox(width: 10.adaptedPx()),
Text(
'about_us'.translation,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium
?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
],
),
),
)
],
),
),
);
}
}