Merge pull request #16 from Iconica-Development/bugfix/more-options-less-padding

less default padding more decoration options
This commit is contained in:
FlutterJorian 2023-03-14 11:35:11 +01:00 committed by GitHub
commit 15b00bac6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 165 additions and 108 deletions

View file

@ -1,2 +0,0 @@
# This is a generated file; do not edit or check into version control.
smart_auth=C:\\Users\\miked\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\smart_auth-1.0.8\\

View file

@ -1 +0,0 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","native_build":true,"dependencies":[]}],"windows":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"smart_auth","path":"C:\\\\Users\\\\miked\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\smart_auth-1.0.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"smart_auth","dependencies":[]}],"date_created":"2023-03-07 10:10:48.544860","version":"3.7.3"}

3
.gitignore vendored
View file

@ -28,3 +28,6 @@ migrate_working_dir/
.dart_tool/ .dart_tool/
.packages .packages
build/ build/
.flutter-plugins-dependencies
.flutter-plugins

View file

@ -1,3 +1,6 @@
## 4.0.0
* More decoration options less default padding
## 3.1.2 ## 3.1.2
* Added textStyle option for email and password fields * Added textStyle option for email and password fields

View file

@ -7,17 +7,20 @@ A package facilitating the basic ingredients for creating functional yet customi
## Setup ## Setup
To use this package, add `flutter_login_widget` as a dependency in your pubspec.yaml file. To use this package, add `flutter_login` as a dependency in your pubspec.yaml file.
## How to use ## How to use
```dart ```dart
final loginOptions = LoginOptions( final loginOptions = LoginOptions(
decoration: const InputDecoration( emailDecoration: const InputDecoration(
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(),
),
passwordDecoration: const InputDecoration(
prefixIcon: Icon(Icons.password),
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
emailInputPrefix: const Icon(Icons.email),
passwordInputPrefix: const Icon(Icons.password),
title: const Text('Login'), title: const Text('Login'),
image: const FlutterLogo(), image: const FlutterLogo(),
requestForgotPasswordButtonBuilder: (context, onPressed, isDisabled) { requestForgotPasswordButtonBuilder: (context, onPressed, isDisabled) {

2
example/.gitignore vendored
View file

@ -41,4 +41,4 @@ app.*.map.json
# Android Studio will place build artifacts here # Android Studio will place build artifacts here
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release

View file

@ -1,16 +0,0 @@
# example
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"

41
example/ios/Podfile Normal file
View file

@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

View file

@ -4,11 +4,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_login/flutter_login.dart'; import 'package:flutter_login/flutter_login.dart';
final loginOptions = LoginOptions( final loginOptions = LoginOptions(
decoration: const InputDecoration( emailDecoration: const InputDecoration(
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(),
),
passwordDecoration: const InputDecoration(
prefixIcon: Icon(Icons.password),
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
emailInputPrefix: const Icon(Icons.email),
passwordInputPrefix: const Icon(Icons.password),
title: const Text('Login Demo'), title: const Text('Login Demo'),
image: const FlutterLogo( image: const FlutterLogo(
size: 200, size: 200,

View file

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <smart_auth/smart_auth_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) smart_auth_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SmartAuthPlugin");
smart_auth_plugin_register_with_registrar(smart_auth_registrar);
} }

View file

@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
smart_auth
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig"

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig"

View file

@ -5,6 +5,8 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import smart_auth
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin"))
} }

40
example/macos/Podfile Normal file
View file

@ -0,0 +1,40 @@
platform :osx, '10.14'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View file

@ -68,7 +68,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "3.1.2" version: "4.0.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter

View file

@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <smart_auth/smart_auth_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
SmartAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SmartAuthPlugin"));
} }

View file

@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
smart_auth
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

View file

@ -9,13 +9,10 @@ class LoginOptions {
this.image, this.image,
this.title, this.title,
this.subtitle, this.subtitle,
this.emailLabel,
this.passwordLabel,
this.emailInputPrefix,
this.passwordInputPrefix,
this.emailTextStyle, this.emailTextStyle,
this.passwordTextStyle, this.passwordTextStyle,
this.decoration = const InputDecoration(), this.emailDecoration = const InputDecoration(),
this.passwordDecoration = const InputDecoration(),
this.initialEmail = '', this.initialEmail = '',
this.initialPassword = '', this.initialPassword = '',
this.translations = const LoginTranslations(), this.translations = const LoginTranslations(),
@ -27,8 +24,6 @@ class LoginOptions {
this.registrationButtonBuilder = _createRegisterButton, this.registrationButtonBuilder = _createRegisterButton,
this.emailInputContainerBuilder = _createEmailInputContainer, this.emailInputContainerBuilder = _createEmailInputContainer,
this.passwordInputContainerBuilder = _createPasswordInputContainer, this.passwordInputContainerBuilder = _createPasswordInputContainer,
this.emailHintText,
this.passwordHintText,
}); });
final ButtonBuilder loginButtonBuilder; final ButtonBuilder loginButtonBuilder;
@ -41,15 +36,10 @@ class LoginOptions {
final Widget? image; final Widget? image;
final Widget? title; final Widget? title;
final Widget? subtitle; final Widget? subtitle;
final Widget? emailLabel; final InputDecoration emailDecoration;
final Widget? passwordLabel; final InputDecoration passwordDecoration;
final Widget? emailInputPrefix;
final Widget? passwordInputPrefix;
final InputDecoration decoration;
final String initialEmail; final String initialEmail;
final String initialPassword; final String initialPassword;
final String? emailHintText;
final String? passwordHintText;
final TextStyle? emailTextStyle; final TextStyle? emailTextStyle;
final TextStyle? passwordTextStyle; final TextStyle? passwordTextStyle;
final LoginTranslations translations; final LoginTranslations translations;
@ -79,9 +69,15 @@ class LoginTranslations {
final String registrationButton; final String registrationButton;
} }
Widget _createEmailInputContainer(Widget child) => child; Widget _createEmailInputContainer(Widget child) => Padding(
padding: const EdgeInsets.only(bottom: 15),
child: child,
);
Widget _createPasswordInputContainer(Widget child) => child; Widget _createPasswordInputContainer(Widget child) => Padding(
padding: const EdgeInsets.only(bottom: 15),
child: child,
);
Widget _createLoginButton( Widget _createLoginButton(
BuildContext context, BuildContext context,

View file

@ -133,14 +133,9 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
style: options.emailTextStyle, style: options.emailTextStyle,
decoration: options.decoration.copyWith( decoration: options.emailDecoration,
hintText: options.emailHintText,
prefixIcon: options.emailInputPrefix,
label: options.emailLabel,
),
), ),
), ),
const SizedBox(height: 24),
options.passwordInputContainerBuilder( options.passwordInputContainerBuilder(
TextFormField( TextFormField(
obscureText: _obscurePassword, obscureText: _obscurePassword,
@ -152,10 +147,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
style: options.passwordTextStyle, style: options.passwordTextStyle,
onFieldSubmitted: (_) => _handleLogin(), onFieldSubmitted: (_) => _handleLogin(),
decoration: options.decoration.copyWith( decoration: options.passwordDecoration.copyWith(
hintText: options.passwordHintText,
label: options.passwordLabel,
prefixIcon: options.passwordInputPrefix,
suffixIcon: IconButton( suffixIcon: IconButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
@ -171,7 +163,6 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
), ),
), ),
), ),
const SizedBox(height: 24),
if (widget.onForgotPassword != null) ...[ if (widget.onForgotPassword != null) ...[
Align( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,

View file

@ -65,60 +65,41 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
var theme = Theme.of(context); var theme = Theme.of(context);
return Form( return Form(
key: _formKey, key: _formKey,
child: Column( child: ConstrainedBox(
mainAxisAlignment: MainAxisAlignment.spaceBetween, constraints: const BoxConstraints(
crossAxisAlignment: CrossAxisAlignment.start, maxWidth: 300,
children: [ ),
Padding( child: Column(
padding: const EdgeInsets.symmetric( mainAxisAlignment: MainAxisAlignment.spaceBetween,
horizontal: 32, crossAxisAlignment: CrossAxisAlignment.start,
vertical: 16, children: [
), _wrapWithDefaultStyle(
child: _wrapWithDefaultStyle( widget.title,
widget.title, theme.textTheme.displaySmall,
theme.textTheme.displaySmall, ) ??
), const SizedBox.shrink(),
), _wrapWithDefaultStyle(
Padding( widget.description,
padding: const EdgeInsets.symmetric( theme.textTheme.bodyMedium,
horizontal: 32, ) ??
vertical: 16, const SizedBox.shrink(),
), Expanded(
child: _wrapWithDefaultStyle( child: Align(
widget.description, child: options.emailInputContainerBuilder(
theme.textTheme.bodyMedium, TextFormField(
), focusNode: _focusNode,
), onChanged: _updateCurrentEmail,
Expanded( validator: widget.options.validations.validateEmail,
flex: 3, initialValue: options.initialEmail,
child: Align( keyboardType: TextInputType.emailAddress,
child: options.emailInputContainerBuilder( textInputAction: TextInputAction.next,
Padding( style: options.emailTextStyle,
padding: const EdgeInsets.all(16), decoration: options.emailDecoration,
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 300,
),
child: TextFormField(
focusNode: _focusNode,
onChanged: _updateCurrentEmail,
validator: widget.options.validations.validateEmail,
initialValue: options.initialEmail,
keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next,
style: options.emailTextStyle,
decoration: options.decoration.copyWith(
prefixIcon: options.emailInputPrefix,
label: options.emailLabel,
),
),
), ),
), ),
), ),
), ),
), AnimatedBuilder(
Expanded(
child: AnimatedBuilder(
animation: _formValid, animation: _formValid,
builder: (context, snapshot) { builder: (context, snapshot) {
return Align( return Align(
@ -139,8 +120,8 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
); );
}, },
), ),
), ],
], ),
), ),
); );
} }

View file

@ -1,6 +1,6 @@
name: flutter_login name: flutter_login
description: Flutter Login Component description: Flutter Login Component
version: 3.1.2 version: 4.0.0
environment: environment:
sdk: ">=2.18.1 <3.0.0" sdk: ">=2.18.1 <3.0.0"