Экран «Вход и регистрация»-8

This commit is contained in:
PROF25-FINAL 2025-05-27 16:11:45 +03:00
parent 7fdb43f46e
commit a572453f98
5 changed files with 150 additions and 1 deletions

View File

@ -0,0 +1,19 @@
import 'package:dio/dio.dart';
class ExceptionCaster {
String cE(Exception e) {
if (e is DioException) {
if (e.response != null) {
try {
return e.response!.data["message"];
} on Exception {
return e.toString();
}
} else {
return e.toString();
}
} else {
return e.toString();
}
}
}

View File

@ -1,5 +1,10 @@
import 'package:flutter/material.dart';
import 'package:matule/domain/services/exception_caster.dart';
import 'package:matule/presentation/widgets/application.dart';
import 'package:matule_query/matule_query.dart';
final BaseUseCase useCase = BaseUseCase(startLoading: () {}, endLoading: () {});
final ExceptionCaster eC = ExceptionCaster();
void main() {
runApp(const Application());

View File

@ -1,4 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:matule/main.dart';
import 'package:matule/presentation/widgets/custom_header.dart';
import 'package:matule/presentation/widgets/utils.dart';
import 'package:matule_uikit/matule_uikit.dart';
class LoginPage extends StatefulWidget {
@ -9,13 +13,87 @@ class LoginPage extends StatefulWidget {
}
class _LoginPageState extends State<LoginPage> {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
@override
Widget build(BuildContext context) {
var theme = CustomTheme.of(context);
return Scaffold(
backgroundColor: theme.palette.whiteOld,
resizeToAvoidBottomInset: false,
body: Column(),
body: Padding(
padding: EdgeInsets.only(top: 103.h, right: 20.w, left: 20.w),
child: Column(
children: [
CustomHeader(
title: "Добро пожаловать!",
description: "Войдите, чтобы пользоваться функциями приложения",
),
Padding(
padding: EdgeInsets.only(top: 64.h),
child: InputWidget(
label: "Вход по E-mail",
hint: "example@mail.com",
error: "",
controller: emailController,
),
),
Padding(
padding: EdgeInsets.only(top: 14.h),
child: InputWidget(
label: "Пароль",
hint: "",
error: "",
controller: passwordController,
),
),
Padding(
padding: EdgeInsets.only(top: 14.h),
child: BigButtonWidget.filled(
theme: theme,
onTap: () {
useCase.login(
emailController.text,
passwordController.text,
(obj) {
// Get.to(ProfilePage());
debugPrint(obj.toString());
},
(e) {
showError(eC.cE(e));
},
);
},
text: "Далее",
),
),
Padding(
padding: EdgeInsets.only(top: 15.h),
child: GestureDetector(
onTap: () {
// Get.to(SignupPage());
},
child: Text(
"Зарегистрироваться",
style: theme.styles.textRegular15.copyWith(
color: theme.palette.accent,
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 59.h),
child: Text(
"Или войдите с помощью",
style: theme.styles.textRegular15.copyWith(
color: theme.palette.placeholderOld,
),
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:matule_uikit/matule_uikit.dart';
class CustomHeader extends StatelessWidget {
final String title;
final String description;
const CustomHeader({
super.key,
required this.title,
required this.description,
});
@override
Widget build(BuildContext context) {
var theme = CustomTheme.of(context);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 23.h,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 16.w,
children: [
Text("🖐️", style: TextStyle(fontSize: 32.sp)),
Text(title, style: theme.styles.title1ExtraBold24),
],
),
Text(
description,
style: theme.styles.textRegular15.copyWith(
color: theme.palette.blackOld,
),
),
],
);
}
}

View File

@ -0,0 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void showError(String e) {
Get.defaultDialog(title: "Произошла ошибка", content: Text(e));
}