Added missing login page (#339)

pull/348/head
Aadarsh Patel 4 years ago committed by GitHub
parent 1ca27ce6db
commit c6f6b5b757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,7 @@ import 'package:provider_shopper/models/cart.dart';
import 'package:provider_shopper/models/catalog.dart';
import 'package:provider_shopper/screens/cart.dart';
import 'package:provider_shopper/screens/catalog.dart';
import 'package:provider_shopper/screens/login.dart';
void main() {
runApp(MyApp());
@ -39,7 +40,8 @@ class MyApp extends StatelessWidget {
theme: appTheme,
initialRoute: '/',
routes: {
'/': (context) => MyCatalog(),
'/': (context) => MyLogin(),
'/catalog': (context) => MyCatalog(),
'/cart': (context) => MyCart(),
},
),

@ -0,0 +1,48 @@
// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
class MyLogin extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
padding: EdgeInsets.all(80.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Welcome',
style: Theme.of(context).textTheme.display4,
),
TextFormField(
decoration: InputDecoration(
hintText: 'Username',
),
),
TextFormField(
decoration: InputDecoration(
hintText: 'Password',
),
obscureText: true,
),
SizedBox(
height: 24,
),
RaisedButton(
color: Colors.yellow,
child: Text('ENTER'),
onPressed: () {
Navigator.pushReplacementNamed(context, '/catalog');
},
)
],
),
),
),
);
}
}

@ -11,6 +11,10 @@ void main() {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Navigating through login page.
await tester.tap(find.text('ENTER'));
await tester.pumpAndSettle();
// Check that shopping cart is empty at start.
await tester.tap(find.byIcon(Icons.shopping_cart));
await tester.pumpAndSettle();

Loading…
Cancel
Save