Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional config for login screen background color gradients (independent of primaryColor) #12

Merged
merged 2 commits into from Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -75,6 +75,9 @@ textFieldStyle | `TextStyle` | Text style for [TextField] input text
buttonStyle | `TextStyle` | Text style for button text
beforeHeroFontSize | `double` | Defines the font size of the title in the login screen (before the hero transition)
afterHeroFontSize | `double` | Defines the font size of the title in the screen after the login screen (after the hero transition)
pageColorLight | `Color` | The optional light background color of login screen; if provided, used for light gradient instead of primaryColor
pageColorDark | `Color` | The optional dark background color of login screen; if provided, used for dark gradient instead of primaryColor


## Examples

Expand Down
5 changes: 4 additions & 1 deletion lib/flutter_login.dart
Expand Up @@ -515,7 +515,10 @@ class _FlutterLoginState extends State<FlutterLogin>
body: Stack(
children: <Widget>[
GradientBox(
colors: [theme.primaryColor, theme.primaryColorDark],
colors: [
loginTheme.pageColorLight ?? theme.primaryColor,
loginTheme.pageColorDark ?? theme.primaryColorDark,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
Expand Down
10 changes: 10 additions & 0 deletions lib/src/providers/login_theme.dart
Expand Up @@ -36,6 +36,8 @@ class LoginButtonTheme {

class LoginTheme with ChangeNotifier {
LoginTheme({
this.pageColorLight,
this.pageColorDark,
this.primaryColor,
this.accentColor,
this.errorColor,
Expand All @@ -52,6 +54,14 @@ class LoginTheme with ChangeNotifier {
this.afterHeroFontSize = 15.0,
});

/// The background color of the login page for light gradient; if provided,
/// overrides the [primaryColor] for page background
final Color pageColorLight;

/// The background color of the login page for dark gradient; if provided,
/// overrides the computed primaryColorDark for page background
final Color pageColorDark;

/// The background color of major parts of the widget like the login screen
/// and buttons
final Color primaryColor;
Expand Down