Skip to content

Commit

Permalink
Create new auth screen (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul019 authored Sep 10, 2024
1 parent e3b0ac5 commit ead26c9
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 69 deletions.
Binary file added assets/images/github-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 110 additions & 67 deletions lib/screens/auth_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:integration_bee_helper/services/basic_services/auth_service.dart';
import 'package:integration_bee_helper/services/basic_services/intl_service.dart';
import 'package:integration_bee_helper/widgets/max_width_wrapper.dart';
import 'package:url_launcher/url_launcher.dart';

class AuthScreen extends StatefulWidget {
const AuthScreen({super.key});
Expand Down Expand Up @@ -82,81 +83,123 @@ class AuthScreenState extends State<AuthScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(MyIntl.of(context).authentication),
),
body: MaxWidthWrapper(
child: Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding:
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 32.0),
child: TextFormField(
decoration: InputDecoration(
icon: const Icon(Icons.email),
labelText: MyIntl.of(context).email,
body: SizedBox(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Image.asset(
'assets/images/background.png',
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
fit: BoxFit.cover,
opacity: const AlwaysStoppedAnimation(0.24),
),
MaxWidthWrapper(
maxWidth: 550,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
MyIntl.of(context).authentication,
style: const TextStyle(fontSize: 24),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextFormField(
decoration: InputDecoration(
icon: const Icon(Icons.email),
labelText: MyIntl.of(context).email,
),
validator: emailAddressValidator,
onSaved: (value) {
email = value ?? "";
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextFormField(
obscureText: true,
decoration: InputDecoration(
icon: const Icon(Icons.lock),
labelText: MyIntl.of(context).password,
),
validator: passwordValidator,
onSaved: (value) {
password = value ?? "";
},
),
),
Padding(
padding: const EdgeInsets.only(top: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: ElevatedButton(
onPressed: onRegisterFormSubmitted,
child: Text(MyIntl.of(context).register),
),
),
const SizedBox(width: 16.0),
Expanded(
child: ElevatedButton(
onPressed: onLoginFormSubmitted,
child: Text(MyIntl.of(context).login),
),
),
],
),
),
],
),
),
),
validator: emailAddressValidator,
onSaved: (value) {
email = value ?? "";
},
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
horizontal: 32.0,
),
child: TextFormField(
obscureText: true,
decoration: InputDecoration(
icon: const Icon(Icons.lock),
labelText: MyIntl.of(context).password,
),
validator: passwordValidator,
onSaved: (value) {
password = value ?? "";
},
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
MyIntl.of(context).copyrightNotice(DateTime.now().year),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
horizontal: 32.0,
),
child: Center(
child: Text(
errorMessage,
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.red),
),
Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
onPressed: () {
final Uri url = Uri.parse(
'https://github.com/paul019/integration_bee_helper',
);
launchUrl(url);
},
icon: Image.asset(
'assets/images/github-mark.png',
width: 30,
height: 30,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
horizontal: 32.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: onRegisterFormSubmitted,
child: Text(MyIntl.of(context).register),
),
ElevatedButton(
onPressed: onLoginFormSubmitted,
child: Text(MyIntl.of(context).login),
),
],
),
)
],
),
)
],
),
),
);
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/max_width_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import 'package:flutter/material.dart';

class MaxWidthWrapper extends StatelessWidget {
final Widget child;
final double maxWidth;

const MaxWidthWrapper({super.key, required this.child});
const MaxWidthWrapper({super.key, required this.child, this.maxWidth = 850});

@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Container(
constraints: const BoxConstraints(maxWidth: 850),
constraints: BoxConstraints(maxWidth: maxWidth),
child: child,
),
);
Expand Down
8 changes: 8 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

#include "generated_plugin_registrant.h"

#include <file_selector_linux/file_selector_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
url_launcher_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
6 changes: 6 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ import Foundation

import audio_session
import cloud_firestore
import file_selector_macos
import firebase_auth
import firebase_core
import firebase_storage
import just_audio
import path_provider_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
64 changes: 64 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
url: "https://pub.dev"
source: hosted
version: "6.3.0"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9"
url: "https://pub.dev"
source: hosted
version: "6.3.2"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e
url: "https://pub.dev"
source: hosted
version: "6.3.1"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af
url: "https://pub.dev"
source: hosted
version: "3.2.0"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
uuid:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies:
firebase_storage: ^11.7.7
image: ^4.2.0
image_picker: ^1.1.2
url_launcher: ^6.3.0

dev_dependencies:
flutter_test:
Expand Down
9 changes: 9 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@
#include "generated_plugin_registrant.h"

#include <cloud_firestore/cloud_firestore_plugin_c_api.h>
#include <file_selector_windows/file_selector_windows.h>
#include <firebase_auth/firebase_auth_plugin_c_api.h>
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <firebase_storage/firebase_storage_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
CloudFirestorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("CloudFirestorePluginCApi"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
FirebaseAuthPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
FirebaseStoragePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseStoragePluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

list(APPEND FLUTTER_PLUGIN_LIST
cloud_firestore
file_selector_windows
firebase_auth
firebase_core
firebase_storage
url_launcher_windows
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down

0 comments on commit ead26c9

Please sign in to comment.