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

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

  ExtraActionsButton({
    this.onSelected,
    this.allComplete = false,
    Key key,
  })
      : super(key: key);

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