Skip to content

Fixes #14 #15

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions lib/pages/home_page/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:xtimer/pages/bottom_sheet.dart';
import 'package:xtimer/pages/home_page/home_bloc.dart';
import 'package:xtimer/pages/home_page/home_events.dart';
import 'package:xtimer/pages/home_page/home_state.dart';
import 'package:xtimer/widgets/safe_app_bar.dart';
import 'package:xtimer/widgets/task_widget.dart';
import 'package:xtimer/pages/new_task_page.dart';

Expand Down Expand Up @@ -61,14 +62,19 @@ class _HomePageState extends State<HomePage> {
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
centerTitle: false,
elevation: 0.0,
backgroundColor: Colors.transparent,
title: Text(
widget.title,
style: TextStyle(
color: Colors.black, fontSize: 32.0, fontWeight: FontWeight.bold),
appBar: SafeAppBar(
appBar: AppBar(
centerTitle: false,
elevation: 0.0,
backgroundColor: Colors.transparent,
title: Text(
widget.title,
style: TextStyle(
color: Colors.black,
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
),
),
),
floatingActionButton: FloatingActionButton(
Expand All @@ -91,8 +97,13 @@ class _HomePageState extends State<HomePage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('No Tasks',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
Text(
'No Tasks',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Text('Add a new Task and it\nwill show up here.',
textAlign: TextAlign.center)
],
Expand All @@ -110,15 +121,17 @@ class _HomePageState extends State<HomePage> {
background: Container(color: Colors.red),
direction: DismissDirection.endToStart,
key: ObjectKey(item),
child: TaskWidget(task: item),
child: TaskWidget(task: item),
onDismissed: (direction) {
tasks.remove(item);
setState(() {});
_homeBloc.dispatch(DeleteTaskEvent(task: item));

Scaffold.of(context)
.showSnackBar(
SnackBar(content: Text("Task Deleted")));
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text("Task Deleted"),
),
);
},
),
);
Expand Down
18 changes: 18 additions & 0 deletions lib/widgets/safe_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';

class SafeAppBar extends StatelessWidget implements PreferredSizeWidget {
final AppBar appBar;

const SafeAppBar({Key key, this.appBar}) : super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.only(top: 36),
child: appBar,
);
}

@override
Size get preferredSize => Size(double.infinity, 92);
}