extra_actions_button.dart 1.26 KB
Newer Older
Brian Egan's avatar
Brian Egan committed
1 2
import 'package:flutter/material.dart';
import 'package:flutter_architecture_samples/flutter_architecture_samples.dart';
3
import 'package:redux_sample/models/models.dart';
Brian Egan's avatar
Brian Egan committed
4 5 6 7 8 9 10 11 12 13

class ExtraActionsButton extends StatelessWidget {
  final PopupMenuItemSelected<ExtraAction> onSelected;
  final bool allComplete;

  ExtraActionsButton({
    this.onSelected,
    this.allComplete = false,
    Key key,
  })
14
      : super(key: ArchSampleKeys.extraActionsButton);
Brian Egan's avatar
Brian Egan committed
15 16 17 18 19 20 21

  @override
  Widget build(BuildContext context) {
    return new PopupMenuButton<ExtraAction>(
      onSelected: onSelected,
      itemBuilder: (BuildContext context) => <PopupMenuItem<ExtraAction>>[
            new PopupMenuItem<ExtraAction>(
22
              key: ArchSampleKeys.toggleAll,
Brian Egan's avatar
Brian Egan committed
23 24 25 26 27 28
              value: ExtraAction.toggleAllComplete,
              child: new Text(allComplete
                  ? ArchSampleLocalizations.of(context).markAllIncomplete
                  : ArchSampleLocalizations.of(context).markAllComplete),
            ),
            new PopupMenuItem<ExtraAction>(
29
              key: ArchSampleKeys.clearCompleted,
Brian Egan's avatar
Brian Egan committed
30 31 32 33 34 35 36 37
              value: ExtraAction.clearCompleted,
              child: new Text(
                  ArchSampleLocalizations.of(context).clearCompleted),
            ),
          ],
    );
  }
}