Prepare everything for the projects creation
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
@@ -38,18 +38,12 @@ class AuthorizationController extends AsyncNotifier<AuthState> {
|
||||
|
||||
Future<void> signin(SignInData form) async {
|
||||
state = const AsyncLoading();
|
||||
|
||||
sleep(Duration(seconds: 10));
|
||||
state = await AsyncValue.guard(() async {
|
||||
final accountsGrpc = ref.read(publicAccountsGrpcProvider);
|
||||
final tokenCtrl = ref.read(tokensControllerProvider.notifier);
|
||||
try {
|
||||
final response = await accountsGrpc.signIn(form.toProto());
|
||||
await tokenCtrl.writeTokenPair(Tokens.fromProto(response.tokenPair));
|
||||
return state.value!.copyWith(isAuthorized: true);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
final response = await accountsGrpc.signIn(form.toProto());
|
||||
await tokenCtrl.writeTokenPair(Tokens.fromProto(response.tokenPair));
|
||||
return state.value!.copyWith(isAuthorized: true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ class _AuthorizationPage extends ConsumerState<AuthorizationPage> {
|
||||
),
|
||||
),
|
||||
|
||||
// ✅ only show decoration if width > 400
|
||||
if (showDecoration) Expanded(flex: 3, child: AuthDecoration()),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:softplayer_web/features/authorization/application/authorization_application.dart';
|
||||
import 'package:softplayer_web/features/authorization/application/sign_in_data.dart';
|
||||
import 'package:toastification/toastification.dart';
|
||||
|
||||
class LoginForm extends ConsumerStatefulWidget {
|
||||
const LoginForm({super.key, required this.toggleAuth});
|
||||
@@ -22,34 +22,32 @@ class _LoginForm extends ConsumerState<LoginForm> {
|
||||
|
||||
Future<void> _submitForm() async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// If valid, you can use the values
|
||||
final email = emailCtrl.text;
|
||||
final password = passwordCtrl.text;
|
||||
final form = SignInData(email: email, password: password);
|
||||
try {
|
||||
await ref.read(authorizationControllerProvider.notifier).signin(form);
|
||||
} catch (e) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
log(e.toString());
|
||||
toastification.show(
|
||||
context: context,
|
||||
type: ToastificationType.error,
|
||||
style: ToastificationStyle.flatColored,
|
||||
alignment: Alignment.topRight,
|
||||
autoCloseDuration: const Duration(seconds: 4),
|
||||
title: const Text('Authentication failed'),
|
||||
description: Text(e.toString()),
|
||||
showProgressBar: false,
|
||||
);
|
||||
}
|
||||
await ref.read(authorizationControllerProvider.notifier).signin(form);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(authorizationControllerProvider);
|
||||
|
||||
ref.listenManual(authorizationControllerProvider, (previous, next) {
|
||||
next.whenOrNull(
|
||||
error: (error, stackTrace) {
|
||||
log("test");
|
||||
Fluttertoast.showToast(
|
||||
msg: "Authentication failed",
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.TOP, // important for web
|
||||
webPosition: "right", // 👈 important for web
|
||||
webBgColor: "#d32f2f", // required for proper visibility
|
||||
timeInSecForIosWeb: 4,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
return LayoutBuilder(
|
||||
builder: ((context, constraints) {
|
||||
return Stack(
|
||||
@@ -116,6 +114,7 @@ class _LoginForm extends ConsumerState<LoginForm> {
|
||||
autofillHints: const [AutofillHints.password],
|
||||
controller: passwordCtrl,
|
||||
obscureText: true,
|
||||
enabled: !state.isLoading,
|
||||
decoration: InputDecoration(hintText: "Password"),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
|
||||
@@ -17,15 +17,37 @@ class _DashboardPage extends ConsumerState<DashboardPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ctrl = ref.read(pingControllerProvider.notifier);
|
||||
log("test");
|
||||
return Container(
|
||||
color: Colors.black87,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
ctrl.ping();
|
||||
},
|
||||
child: Text("pong"),
|
||||
),
|
||||
return LayoutBuilder(
|
||||
builder: ((context, constraints) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Softplayer"),
|
||||
actions: [
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
items: [
|
||||
DropdownMenuItem(value: "test", child: Text("test")),
|
||||
DropdownMenuItem(value: "test2", child: Text("test2")),
|
||||
],
|
||||
onChanged: (value) => log(value!),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
ctrl.ping();
|
||||
},
|
||||
child: Text("pong"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
10
pubspec.lock
10
pubspec.lock
@@ -264,6 +264,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fluttertoast:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluttertoast
|
||||
sha256: "7903c9d5339173497bfecbc23bc4212f5a87e0edfac2e1693fb74465ea67da7e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.1.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -856,4 +864,4 @@ packages:
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.11.5 <4.0.0"
|
||||
flutter: ">=3.38.4"
|
||||
flutter: ">=3.41.0"
|
||||
|
||||
@@ -24,6 +24,7 @@ dependencies:
|
||||
flutter_secure_storage: ^10.2.0
|
||||
jwt_decoder: ^2.0.1
|
||||
toastification: ^3.2.0
|
||||
fluttertoast: ^9.1.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user