-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add new welcome page #917
Merged
Merged
Add new welcome page #917
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7135e6f
temp
nilsreichardt 5d009bd
Add license header
nilsreichardt 1bfdbc7
Remove welcome page temp
nilsreichardt b3e81cc
Fix comment
nilsreichardt 1b01175
add comment for gradient
nilsreichardt 58486c5
Add const
nilsreichardt 8002fd2
More const
nilsreichardt 069e57b
Add key to navigate to login page
nilsreichardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; | ||
import 'package:sharezone/auth/login_page.dart'; | ||
import 'package:sharezone/onboarding/sign_up/sign_up_page.dart'; | ||
import 'package:sharezone_widgets/sharezone_widgets.dart'; | ||
|
||
class MobileWelcomePage extends StatelessWidget { | ||
const MobileWelcomePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: const Color(0xFFE7EBED), | ||
body: Stack( | ||
children: const [ | ||
_BackgroundImage(), | ||
_Bottom(), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _BackgroundImage extends StatelessWidget { | ||
const _BackgroundImage(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final isTablet = MediaQuery.of(context).size.shortestSide >= 600; | ||
final isPortrait = | ||
MediaQuery.of(context).orientation == Orientation.portrait; | ||
return Positioned.fill( | ||
child: Stack( | ||
children: [ | ||
Align( | ||
alignment: Alignment.topCenter, | ||
child: Image.asset( | ||
'assets/images/welcome-page-background.png', | ||
fit: BoxFit.cover, | ||
height: | ||
MediaQuery.of(context).size.height * (isTablet ? 0.9 : 0.8), | ||
semanticLabel: | ||
'Hintergrundbild der Willkommens-Seite mit 5 Handys, die die Sharezone-App zeigen.', | ||
), | ||
), | ||
Positioned.fill( | ||
child: Container( | ||
// Add white (bottom) to transparent (top) gradient that is placed at | ||
// the bottom of the screen. It should have a height of 30% of the | ||
// screen height. | ||
decoration: BoxDecoration( | ||
gradient: LinearGradient( | ||
begin: Alignment.bottomCenter, | ||
end: Alignment.topCenter, | ||
colors: [ | ||
Colors.white, | ||
// We shouldn't use `Colors.transparent` here, because it | ||
// will destroy the gradient effect. | ||
Colors.white.withOpacity(0.0), | ||
], | ||
stops: [ | ||
if (isTablet) isPortrait ? 0.15 : 0.22 else 0.3, | ||
0.5, | ||
], | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _Bottom extends StatelessWidget { | ||
const _Bottom(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Positioned.fill( | ||
child: SafeArea( | ||
child: Padding( | ||
padding: const EdgeInsets.all(12), | ||
child: DefaultTextStyle.merge( | ||
textAlign: TextAlign.center, | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
children: AnimationConfiguration.toStaggeredList( | ||
duration: const Duration(milliseconds: 1250), | ||
childAnimationBuilder: (widget) => SlideAnimation( | ||
verticalOffset: 20, | ||
child: FadeInAnimation(child: widget), | ||
), | ||
children: const [ | ||
_Headline(), | ||
_SubHeadline(), | ||
_NewAtSharezoneButton(), | ||
_AlreadyHaveAnAccountButton(), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _Headline extends StatelessWidget { | ||
const _Headline(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Padding( | ||
padding: EdgeInsets.only(bottom: 4), | ||
child: Text( | ||
'Gemeinsam den\nSchulalltag organisieren 🚀', | ||
style: TextStyle( | ||
fontSize: 22, | ||
height: 1.1, | ||
color: Colors.black, | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _SubHeadline extends StatelessWidget { | ||
const _SubHeadline(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Padding( | ||
padding: EdgeInsets.only(bottom: 20), | ||
child: Text( | ||
'Optional kannst du Sharezone auch komplett alleine verwenden.', | ||
style: TextStyle( | ||
color: Colors.grey, | ||
fontSize: 12, | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _NewAtSharezoneButton extends StatelessWidget { | ||
const _NewAtSharezoneButton(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.only(bottom: 10), | ||
child: _BaseButton( | ||
text: const Text( | ||
'Ich bin neu bei Sharezone 👋', | ||
textAlign: TextAlign.center, | ||
), | ||
onPressed: () => Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => const SignUpPage( | ||
withLogin: false, | ||
withBackButton: true, | ||
), | ||
settings: const RouteSettings(name: SignUpPage.tag), | ||
), | ||
), | ||
backgroundColor: Theme.of(context).primaryColor, | ||
foregroundColor: Colors.white, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _AlreadyHaveAnAccountButton extends StatelessWidget { | ||
const _AlreadyHaveAnAccountButton(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return _BaseButton( | ||
key: const Key('go-to-login-button-E2E'), | ||
text: Column( | ||
children: const [ | ||
Text( | ||
'Anmelden', | ||
style: TextStyle( | ||
fontSize: 18, | ||
color: Colors.black, | ||
), | ||
), | ||
Text( | ||
'Mit existierendem Konto anmelden', | ||
style: TextStyle( | ||
fontSize: 12, | ||
color: Colors.grey, | ||
), | ||
), | ||
], | ||
), | ||
onPressed: () => Navigator.pushNamed(context, LoginPage.tag), | ||
foregroundColor: Colors.grey, | ||
backgroundColor: Colors.white, | ||
borderSide: BorderSide( | ||
color: Colors.grey[300]!, | ||
width: 1, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _BaseButton extends StatelessWidget { | ||
const _BaseButton({ | ||
super.key, | ||
required this.text, | ||
required this.onPressed, | ||
required this.backgroundColor, | ||
required this.foregroundColor, | ||
this.borderSide = BorderSide.none, | ||
}); | ||
|
||
final Widget text; | ||
final VoidCallback onPressed; | ||
final BorderSide borderSide; | ||
final Color backgroundColor; | ||
final Color foregroundColor; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ConstrainedBox( | ||
constraints: BoxConstraints( | ||
minWidth: MediaQuery.of(context).textScaleFactor * 300, | ||
), | ||
child: ElevatedButton( | ||
onPressed: onPressed, | ||
child: Padding( | ||
padding: const EdgeInsets.all(12), | ||
child: DefaultTextStyle.merge( | ||
// Even though the text is already centered with `DefaultTextStyle` | ||
// of the `_Bottom` widget`, we need to set `textAlign` to `center` | ||
// here, because otherwise the text will be aligned to the left. | ||
textAlign: TextAlign.center, | ||
child: text, | ||
style: TextStyle( | ||
// For the golden tests we need to set the font family again, | ||
// because otherwise 'Ahem' will be used. | ||
// | ||
// Can be removed when the following bug is resolved: | ||
// https://github.com/eBay/flutter_glove_box/issues/103. | ||
fontFamily: rubik, | ||
), | ||
), | ||
), | ||
style: ElevatedButton.styleFrom( | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(12), | ||
side: borderSide, | ||
), | ||
foregroundColor: foregroundColor, | ||
backgroundColor: backgroundColor, | ||
textStyle: const TextStyle( | ||
fontWeight: FontWeight.normal, | ||
fontSize: 18, | ||
), | ||
elevation: 0, | ||
shadowColor: Colors.transparent, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+255 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_dark.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+183 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_dark.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+81.8 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_dark.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+570 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_dark.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+890 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_dark.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+255 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_light.iphone11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+183 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_light.phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+81.8 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_light.phone_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+570 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_light.tablet_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+890 KB
app/test_goldens/onboarding/goldens/mobile_welcome_page_light.tablet_portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:golden_toolkit/golden_toolkit.dart'; | ||
import 'package:sharezone/onboarding/mobile_welcome_page.dart'; | ||
import 'package:sharezone_widgets/sharezone_widgets.dart'; | ||
|
||
void main() { | ||
group(MobileWelcomePage, () { | ||
Future<void> _pumpPage(WidgetTester tester, {ThemeData? theme}) async { | ||
await tester.pumpWidgetBuilder( | ||
MobileWelcomePage(), | ||
wrapper: materialAppWrapper(theme: theme), | ||
); | ||
} | ||
|
||
testGoldens('renders as expected (light theme)', (tester) async { | ||
await _pumpPage(tester, theme: lightTheme); | ||
|
||
await multiScreenGolden(tester, 'mobile_welcome_page_light'); | ||
}); | ||
|
||
// At the moment, the screen is hard coded to dark mode. This test will just | ||
// ensures that the screen is still rendered with the correct colors. | ||
// | ||
// Ticket: https://github.com/SharezoneApp/sharezone-app/issues/916 | ||
testGoldens('renders as expected (dark theme)', (tester) async { | ||
await _pumpPage(tester, theme: darkTheme); | ||
|
||
await multiScreenGolden(tester, 'mobile_welcome_page_dark'); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nilsreichardt This looks kinda off though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is true. However, I think it's okay for now because making it pretty for phone landscape adds some complexity and as long it's looks okay and doesn't throw exceptions I would use it for now