Начальный коммит
This commit is contained in:
148
lib/Pages/views/login_screen.dart
Normal file
148
lib/Pages/views/login_screen.dart
Normal file
@@ -0,0 +1,148 @@
|
||||
// lib/pages/login_screen.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:Stocky/Pages/controllers/AuthController.dart';
|
||||
import 'package:Stocky/Pages/widgets/phone_input_formatter.dart';
|
||||
import 'package:Stocky/classes/styles.dart';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:extended_masked_text/extended_masked_text.dart';
|
||||
|
||||
class LoginScreen extends StatelessWidget {
|
||||
final AuthController controller = Get.put(AuthController());
|
||||
|
||||
LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Вход", style: AppStyles.titleLarge)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Добро пожаловать!",
|
||||
style: AppStyles.titleLarge, // ← Стиль заголовка
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Obx(() => _buildAuthForm(controller)),
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
"Мы отправим SMS для подтверждения",
|
||||
style: AppStyles.description, // ← Стиль описания
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAuthForm(AuthController controller) {
|
||||
if (controller.state == 'inputPhone') {
|
||||
return _buildPhoneInputForm(controller);
|
||||
} else {
|
||||
return _buildCodeInputForm(controller);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPhoneInputForm(AuthController controller) {
|
||||
final phonecontrol = MaskedTextController(mask: '+7 (000) 000-00-00');
|
||||
return Column(
|
||||
children: [
|
||||
// Ввод номера
|
||||
TextField(
|
||||
controller: phonecontrol,
|
||||
onChanged: controller.phoneNumberInput,
|
||||
keyboardType: TextInputType.phone,
|
||||
decoration: InputDecoration(
|
||||
labelText: "Номер телефона",
|
||||
prefixIcon: AppStyles.createPrimaryIcon(Icons.phone),
|
||||
hintText: "+7 (999) 123-45-67",
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
filled: true,
|
||||
fillColor: Colors.grey[100],
|
||||
labelStyle: AppStyles.body, // ← Стиль для метки
|
||||
hintStyle: AppStyles.description, // ← Стиль для подсказки
|
||||
),
|
||||
inputFormatters: [PhoneInputFormatter()],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.sendCode,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"Отправить код",
|
||||
style: AppStyles.title, // ← Стиль текста кнопки
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCodeInputForm(AuthController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
// Ввод кода
|
||||
TextField(
|
||||
controller: MaskedTextController(mask: '00000'),
|
||||
onChanged: controller.verificationCodeInput,
|
||||
keyboardType: TextInputType.number,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: "Код подтверждения",
|
||||
prefixIcon: AppStyles.createPrimaryIcon(Icons.lock),
|
||||
hintText: "Введите 6-значный код",
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
filled: true,
|
||||
fillColor: Colors.grey[100],
|
||||
labelStyle: AppStyles.body,
|
||||
hintStyle: AppStyles.description,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Text("Подтвердить", style: AppStyles.title),
|
||||
),
|
||||
),
|
||||
|
||||
// Кнопка "Назад"
|
||||
const SizedBox(height: 20),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
controller.setState('inputPhone');
|
||||
controller.verificationCode('');
|
||||
},
|
||||
child: Text(
|
||||
"Вернуться к вводу номера",
|
||||
style: AppStyles.link, // ← Стиль ссылки
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user