Skip to content

Commit

Permalink
refactor: sign in page to welcome page (#3)
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
tnc1997 authored Mar 24, 2021
1 parent 0ef121a commit d9f5349
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 52 deletions.
4 changes: 4 additions & 0 deletions images/image-search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class _AppState extends State<App> {
primaryVariant: Colors.red[700]!,
secondary: Colors.red,
secondaryVariant: Colors.red[700]!,
onPrimary: Colors.black,
onSecondary: Colors.black,
onPrimary: Colors.white,
onSecondary: Colors.white,
),
),
darkTheme: ThemeData.from(
Expand All @@ -148,8 +148,8 @@ class _AppState extends State<App> {
primaryVariant: Colors.red[700]!,
secondary: Colors.red,
secondaryVariant: Colors.red[700]!,
onPrimary: Colors.black,
onSecondary: Colors.black,
onPrimary: Colors.white,
onSecondary: Colors.white,
),
),
themeMode: ThemeState.of(context).themeMode,
Expand Down
29 changes: 0 additions & 29 deletions lib/pages/sign_in_page.dart

This file was deleted.

153 changes: 153 additions & 0 deletions lib/pages/welcome_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import 'package:album_searcher_for_google_photos/widgets/sign_in_elevated_button.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:url_launcher/url_launcher.dart';

class WelcomePage extends StatefulWidget {
const WelcomePage({Key? key}) : super(key: key);

@override
_WelcomePageState createState() => _WelcomePageState();
}

class _WelcomePageState extends State<WelcomePage> {
late TapGestureRecognizer _tapGestureRecognizer;

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: 800,
),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Card(
margin: const EdgeInsets.all(8),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8),
child: CircleAvatar(
child: SvgPicture.asset(
'images/image-search.svg',
width: 50,
height: 50,
color: Theme.of(context).colorScheme.onPrimary,
),
backgroundColor:
Theme.of(context).colorScheme.primary,
radius: 40,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'Welcome to Album Searcher for Google Photos',
style: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'Album Searcher for Google Photos gives you an enhanced search experience for shared albums.',
textAlign: TextAlign.center,
),
),
],
),
),
),
Card(
margin: const EdgeInsets.all(8),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'Sign in with Google to continue to Album Searcher for Google Photos.',
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'Album Searcher for Google Photos will have read access to your photos library.',
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Text.rich(
TextSpan(
children: [
TextSpan(
text:
'By continuing to Album Searcher for Google Photos you agree to the ',
),
TextSpan(
text: 'Terms of Service',
style: Theme.of(context)
.textTheme
.bodyText2!
.copyWith(
color: Theme.of(context)
.colorScheme
.primary,
),
recognizer: _tapGestureRecognizer,
),
TextSpan(
text: '.',
),
],
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: SignInElevatedButton(),
),
],
),
),
),
],
),
),
),
),
),
);
}

@override
void dispose() {
_tapGestureRecognizer.dispose();
super.dispose();
}

@override
void initState() {
super.initState();
_tapGestureRecognizer = TapGestureRecognizer()
..onTap = () async => await launch('/terms.html');
}
}
14 changes: 7 additions & 7 deletions lib/route_information_parsers/app_route_information_parser.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:album_searcher_for_google_photos/route_paths/album_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/home_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/settings_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/sign_in_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/welcome_route_path.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

class AppRouteInformationParser extends RouteInformationParser<RoutePath> {
@override
Expand All @@ -16,8 +16,8 @@ class AppRouteInformationParser extends RouteInformationParser<RoutePath> {
switch (uri.pathSegments.length) {
case 1:
switch (uri.pathSegments[0]) {
case 'login':
return SynchronousFuture(SignInRoutePath());
case 'welcome':
return SynchronousFuture(WelcomeRoutePath());
case 'settings':
return SynchronousFuture(SettingsRoutePath());
}
Expand Down Expand Up @@ -46,9 +46,9 @@ class AppRouteInformationParser extends RouteInformationParser<RoutePath> {
return RouteInformation(
location: '/albums/${configuration.id}',
);
} else if (configuration is SignInRoutePath) {
} else if (configuration is WelcomeRoutePath) {
return RouteInformation(
location: '/login',
location: '/welcome',
);
} else if (configuration is SettingsRoutePath) {
return RouteInformation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:album_searcher_for_google_photos/route_paths/route_path.dart';

class SignInRoutePath extends RoutePath {
const SignInRoutePath();
class WelcomeRoutePath extends RoutePath {
const WelcomeRoutePath();
}
12 changes: 6 additions & 6 deletions lib/router_delegates/app_router_delegate.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:album_searcher_for_google_photos/pages/album_page.dart';
import 'package:album_searcher_for_google_photos/pages/main_page.dart';
import 'package:album_searcher_for_google_photos/pages/sign_in_page.dart';
import 'package:album_searcher_for_google_photos/pages/welcome_page.dart';
import 'package:album_searcher_for_google_photos/route_paths/album_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/home_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/settings_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/sign_in_route_path.dart';
import 'package:album_searcher_for_google_photos/route_paths/welcome_route_path.dart';
import 'package:album_searcher_for_google_photos/states/authentication_state.dart';
import 'package:album_searcher_for_google_photos/states/router_state.dart';
import 'package:flutter/material.dart';

class AppRouterDelegate extends RouterDelegate<RoutePath>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<RoutePath> {
Expand All @@ -29,7 +29,7 @@ class AppRouterDelegate extends RouterDelegate<RoutePath>
@override
RoutePath? get currentConfiguration {
if (authenticationStateData.client == null) {
return SignInRoutePath();
return WelcomeRoutePath();
}

final selectedAlbum = routerStateData.selectedAlbum;
Expand Down Expand Up @@ -66,8 +66,8 @@ class AppRouterDelegate extends RouterDelegate<RoutePath>
),
] else
const MaterialPage<void>(
child: SignInPage(),
key: ValueKey('sign_in_page'),
child: WelcomePage(),
key: ValueKey('welcome_page'),
),
],
onPopPage: (route, result) {
Expand Down
37 changes: 36 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_svg:
dependency: "direct main"
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.21.0-nullsafety.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -317,6 +324,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0-nullsafety.0"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0-nullsafety.0"
path_provider_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -345,6 +366,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -622,6 +650,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.2"
yaml:
dependency: transitive
description:
Expand All @@ -631,4 +666,4 @@ packages:
version: "3.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
flutter: ">=1.24.0-7.0"
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ environment:
dependencies:
flutter:
sdk: flutter

flutter_svg: ^0.21.0-nullsafety.0
http: ^0.13.0
json_annotation: ^4.0.0
oauth2: ^2.0.0
Expand All @@ -34,10 +34,9 @@ dependencies:
url_launcher: ^6.0.0

dev_dependencies:
build_runner: ^1.0.0
flutter_test:
sdk: flutter

build_runner: ^1.0.0
json_serializable: ^4.0.0

dependency_overrides:
Expand Down Expand Up @@ -80,6 +79,7 @@ flutter:
assets:
- files/browser_client_secret.json
- files/desktop_client_secret.json
- images/image-search.svg
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
Expand Down

0 comments on commit d9f5349

Please sign in to comment.