details_screen.dart 3.07 KB
Newer Older
1
import 'package:built_redux_sample/containers/edit_todo.dart';
2
import 'package:built_redux_sample/models/models.dart';
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_architecture_samples/flutter_architecture_samples.dart';

class DetailsScreen extends StatelessWidget {
  final Todo todo;
  final Function onDelete;
  final Function(bool) toggleCompleted;

  DetailsScreen({
    Key key,
    @required this.todo,
    @required this.onDelete,
    @required this.toggleCompleted,
  })
18
      : super(key: ArchSampleKeys.todoDetailsScreen);
19 20 21 22 23 24 25 26 27 28 29 30

  @override
  Widget build(BuildContext context) {
    final localizations = ArchSampleLocalizations.of(context);

    return new Scaffold(
      appBar: new AppBar(
        title: new Text(localizations.todoDetails),
        actions: [
          new IconButton(
            tooltip: localizations.deleteTodo,
            icon: new Icon(Icons.delete),
31
            key: ArchSampleKeys.deleteTodoButton,
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
            onPressed: () {
              onDelete();
              Navigator.pop(context, todo);
            },
          )
        ],
      ),
      body: new Padding(
        padding: new EdgeInsets.all(16.0),
        child: new ListView(
          children: [
            new Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                new Padding(
                  padding: new EdgeInsets.only(right: 8.0),
                  child: new Checkbox(
49
                    key: ArchSampleKeys.detailsTodoItemCheckbox,
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
                    value: todo.complete,
                    onChanged: toggleCompleted,
                  ),
                ),
                new Expanded(
                  child: new Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      new Padding(
                        padding: new EdgeInsets.only(
                          top: 8.0,
                          bottom: 16.0,
                        ),
                        child: new Text(
                          todo.task,
65
                          key: ArchSampleKeys.detailsTodoItemTask,
66 67 68 69 70
                          style: Theme.of(context).textTheme.headline,
                        ),
                      ),
                      new Text(
                        todo.note,
71
                        key: ArchSampleKeys.detailsTodoItemNote,
72 73 74 75 76 77 78 79 80 81 82
                        style: Theme.of(context).textTheme.subhead,
                      )
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
83
        key: ArchSampleKeys.editTodoFab,
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
        tooltip: localizations.editTodo,
        child: new Icon(Icons.edit),
        onPressed: () {
          Navigator.of(context).push(
            new MaterialPageRoute(
              builder: (context) {
                return new EditTodo(
                  todo: todo,
                );
              },
            ),
          );
        },
      ),
    );
  }
}