Added docs for the screens
This commit is contained in:
parent
96d9e06ffc
commit
f6bae2a081
5 changed files with 45 additions and 21 deletions
|
|
@ -16,6 +16,7 @@ class HomeScreen extends StatefulWidget {
|
|||
class _HomeScreenState extends State<HomeScreen> {
|
||||
static const _searchBoxHeight = 50.0;
|
||||
|
||||
/// An instance of the bloc for this screen.
|
||||
final HomeBloc bloc = HomeBloc();
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -6,14 +6,9 @@ import 'package:flutter/material.dart';
|
|||
import '../services/auth_service.dart';
|
||||
|
||||
class InitialLoadingScreen extends StatelessWidget {
|
||||
/// An instance of the auth service.
|
||||
final AuthService _auth = authService;
|
||||
|
||||
void redirectUser(BuildContext context) async {
|
||||
final user = await _auth.currentUser;
|
||||
final routeToBePushed = user == null ? 'login/' : 'home/';
|
||||
Navigator.of(context).pushReplacementNamed(routeToBePushed);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
|
|
@ -43,4 +38,14 @@ class InitialLoadingScreen extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Pushed a new route depending on the user status.
|
||||
///
|
||||
/// Redirect to the home screen if there's a user stored locally, redirect
|
||||
/// to the login screen otherwise.
|
||||
void redirectUser(BuildContext context) async {
|
||||
final user = await _auth.currentUser;
|
||||
final routeToBePushed = user == null ? 'login/' : 'home/';
|
||||
Navigator.of(context).pushReplacementNamed(routeToBePushed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import '../widgets/logo.dart';
|
|||
import '../widgets/gradient_touchable_container.dart';
|
||||
|
||||
class LoginScreen extends StatelessWidget {
|
||||
final _authService = authService;
|
||||
/// An instance of the auth service.
|
||||
final AuthService _authService = authService;
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -40,13 +41,6 @@ class LoginScreen extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> onLoginButtonTap(BuildContext context) async {
|
||||
final user = await _authService.googleLoginAndSignup();
|
||||
if (user != null) {
|
||||
Navigator.of(context).pushReplacementNamed('home/');
|
||||
}
|
||||
}
|
||||
|
||||
Widget getButtonBody() {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
@ -71,4 +65,14 @@ class LoginScreen extends StatelessWidget {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Signs in a user.
|
||||
///
|
||||
/// Redirects to thehome screen if the login was successful.
|
||||
Future<void> onLoginButtonTap(BuildContext context) async {
|
||||
final user = await _authService.googleLoginAndSignup();
|
||||
if (user != null) {
|
||||
Navigator.of(context).pushReplacementNamed('home/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class NewImageScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _NewImageScreenState extends State<NewImageScreen> {
|
||||
/// An instance of the bloc for this scree.
|
||||
final NewImageBloc bloc = NewImageBloc();
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -87,13 +88,6 @@ class _NewImageScreenState extends State<NewImageScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> takePicture() async {
|
||||
final File imgFile = await ImagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
);
|
||||
bloc.changePicture(imgFile);
|
||||
}
|
||||
|
||||
Widget buildEventSection(NewImageBloc bloc) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
|
|
@ -140,11 +134,22 @@ class _NewImageScreenState extends State<NewImageScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
/// Saves the image to the storage bucket.
|
||||
void onSubmit() async {
|
||||
await bloc.submit();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
/// Prompts the user to take a picture.
|
||||
///
|
||||
/// Updates the file in the bloc.
|
||||
Future<void> takePicture() async {
|
||||
final File imgFile = await ImagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
);
|
||||
bloc.changePicture(imgFile);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
bloc.dispose();
|
||||
super.dispose();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import '../widgets/gradient_touchable_container.dart';
|
|||
import '../widgets/priority_selector.dart';
|
||||
|
||||
class TaskScreen extends StatefulWidget {
|
||||
/// Wether the Screen is going to edit a current task or create a new one.
|
||||
final bool isEdit;
|
||||
|
||||
TaskScreen({
|
||||
|
|
@ -22,7 +23,12 @@ class TaskScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _TaskScreenState extends State<TaskScreen> {
|
||||
/// An instance of this screen's bloc.
|
||||
final TaskBloc bloc = TaskBloc();
|
||||
|
||||
/// The initial value for the text field.
|
||||
///
|
||||
/// This only gets used whent the screen is set to edit.
|
||||
String textFieldInitialValue;
|
||||
|
||||
initState() {
|
||||
|
|
@ -148,6 +154,9 @@ class _TaskScreenState extends State<TaskScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
/// Updates or creates a task.
|
||||
///
|
||||
/// The action is determined by the [isEdit] property.
|
||||
void onSubmit(BuildContext context) async {
|
||||
await bloc.submit(widget.isEdit);
|
||||
Navigator.of(context).pop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue