Actions...
This commit is contained in:
parent
b51bdfffbc
commit
89fb62918c
|
|
@ -0,0 +1,54 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
|
||||
enum ActionMenuButtonType {
|
||||
filter,
|
||||
sort,
|
||||
}
|
||||
|
||||
class ActionMenuChoice {
|
||||
const ActionMenuChoice(this.action, {this.label, this.icon});
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final ActionMenuButtonType action;
|
||||
}
|
||||
|
||||
class ActionMenuButton extends StatelessWidget {
|
||||
final List<ActionMenuChoice> actions;
|
||||
final Function onSelected;
|
||||
|
||||
ActionMenuButton({this.actions, this.onSelected});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton<ActionMenuChoice>(
|
||||
// overflow menu
|
||||
onSelected: (ActionMenuChoice choice) => this.onSelected(choice),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return actions.map((ActionMenuChoice choice) {
|
||||
var icon, label;
|
||||
switch (choice.action) {
|
||||
case ActionMenuButtonType.filter:
|
||||
icon = choice.icon ?? Icons.filter_list;
|
||||
label = choice.label ?? AppLocalization.of(context).filter;
|
||||
break;
|
||||
case ActionMenuButtonType.sort:
|
||||
icon = choice.icon ?? Icons.sort;
|
||||
label = choice.label ?? AppLocalization.of(context).sort;
|
||||
break;
|
||||
}
|
||||
return new PopupMenuItem<ActionMenuChoice>(
|
||||
value: choice,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(icon),
|
||||
SizedBox(width: 15.0),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import 'package:invoiceninja/ui/product/product_details_vm.dart';
|
|||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/ui/app/action_popup_menu.dart';
|
||||
|
||||
class ProductScreen extends StatelessWidget {
|
||||
ProductScreen() : super(key: NinjaKeys.productHome);
|
||||
|
|
@ -19,6 +20,24 @@ class ProductScreen extends StatelessWidget {
|
|||
appBar: AppBar(
|
||||
title: Text(AppLocalization.of(context).products),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {},
|
||||
),
|
||||
ActionMenuButton(
|
||||
onSelected: (ActionMenuChoice choice) {
|
||||
switch (choice.action) {
|
||||
case ActionMenuButtonType.sort:
|
||||
break;
|
||||
case ActionMenuButtonType.filter:
|
||||
break;
|
||||
}
|
||||
},
|
||||
actions: [
|
||||
ActionMenuChoice(ActionMenuButtonType.sort),
|
||||
ActionMenuChoice(ActionMenuButtonType.filter)
|
||||
],
|
||||
)
|
||||
//FilterSelector(visible: activeTab == AppTab.products),
|
||||
//ExtraActionsContainer(),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ class AppLocalization {
|
|||
static Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
'log_out': 'Log Out',
|
||||
'filter': 'Filter',
|
||||
'sort': 'Sort',
|
||||
'search': 'Search',
|
||||
'dashboard': 'Dashboard',
|
||||
'refresh_complete': 'Refresh Complete',
|
||||
'please_enter_your_email': 'Please enter your email',
|
||||
|
|
@ -37,6 +40,9 @@ class AppLocalization {
|
|||
};
|
||||
|
||||
String get logOut => _localizedValues[locale.languageCode]['log_out'];
|
||||
String get filter => _localizedValues[locale.languageCode]['filter'];
|
||||
String get sort => _localizedValues[locale.languageCode]['sort'];
|
||||
String get search => _localizedValues[locale.languageCode]['search'];
|
||||
String get dashboard => _localizedValues[locale.languageCode]['dashboard'];
|
||||
String get refreshComplete => _localizedValues[locale.languageCode]['refresh_complete'];
|
||||
String get pleaseEnterYourEmail => _localizedValues[locale.languageCode]['please_enter_your_email'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue