2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 18:25:26 +00:00

Refactor of translation lookup!

This commit is contained in:
Oliver Walters
2021-05-19 23:33:28 +10:00
parent b86025013d
commit 2a3e83509f
26 changed files with 339 additions and 353 deletions

View File

@ -2,17 +2,15 @@
import 'package:InvenTree/api.dart';
import 'package:InvenTree/app_settings.dart';
import 'package:InvenTree/inventree/part.dart';
import 'package:InvenTree/preferences.dart';
import 'package:InvenTree/widget/progress.dart';
import 'package:InvenTree/widget/search.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:InvenTree/widget/fields.dart';
import 'package:InvenTree/widget/dialogs.dart';
import 'package:InvenTree/widget/snacks.dart';
import 'package:InvenTree/widget/part_detail.dart';
import 'package:InvenTree/widget/drawer.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:InvenTree/widget/paginator.dart';
@ -39,7 +37,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
final _editCategoryKey = GlobalKey<FormState>();
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).partCategory;
String getAppBarTitle(BuildContext context) => L10().partCategory;
@override
List<Widget> getAppBarActions(BuildContext context) {
@ -71,7 +69,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
tooltip: L10().edit,
onPressed: _editCategoryDialog,
)
);
@ -99,7 +97,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
var _description;
showFormDialog(
I18N.of(context).editCategory,
L10().editCategory,
key: _editCategoryKey,
callback: () {
_editCategory({
@ -109,12 +107,12 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
},
fields: <Widget>[
StringField(
label: I18N.of(context).name,
label: L10().name,
initial: category.name,
onSaved: (value) => _name = value
),
StringField(
label: I18N.of(context).description,
label: L10().description,
initial: category.description,
onSaved: (value) => _description = value
)
@ -163,7 +161,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
if (category == null) {
return Card(
child: ListTile(
title: Text(I18N.of(context).partCategoryTopLevel)
title: Text(L10().partCategoryTopLevel)
)
);
} else {
@ -180,7 +178,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
if (extra) {
children.add(
ListTile(
title: Text(I18N.of(context).parentCategory),
title: Text(L10().parentCategory),
subtitle: Text("${category.parentpathstring}"),
leading: FaIcon(FontAwesomeIcons.levelUpAlt),
onTap: () {
@ -215,17 +213,17 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.sitemap),
label: I18N.of(context).details,
label: L10().details,
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.shapes),
label: I18N.of(context).parts,
label: L10().parts,
),
// TODO - Add the "actions" item back in
/*
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
label: I18N.of(context).actions
label: L10().actions
),
*/
]
@ -237,7 +235,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
getCategoryDescriptionCard(),
ListTile(
title: Text(
I18N.of(context).subcategories,
L10().subcategories,
style: TextStyle(fontWeight: FontWeight.bold)
),
trailing: _subcategories.isNotEmpty ? Text("${_subcategories.length}") : null,
@ -248,8 +246,8 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
tiles.add(progressIndicator());
} else if (_subcategories.length == 0) {
tiles.add(ListTile(
title: Text(I18N.of(context).noSubcategories),
subtitle: Text(I18N.of(context).noSubcategoriesAvailable)
title: Text(L10().noSubcategories),
subtitle: Text(L10().noSubcategoriesAvailable)
));
} else {
tiles.add(SubcategoryList(_subcategories));
@ -263,7 +261,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
List<Widget> tiles = [
getCategoryDescriptionCard(extra: false),
ListTile(
title: Text(I18N.of(context).actions,
title: Text(L10().actions,
style: TextStyle(fontWeight: FontWeight.bold)
)
)

View File

@ -2,13 +2,12 @@
import 'package:InvenTree/api.dart';
import 'package:InvenTree/inventree/company.dart';
import 'package:InvenTree/widget/dialogs.dart';
import 'package:InvenTree/widget/drawer.dart';
import 'package:InvenTree/widget/fields.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
class CompanyDetailWidget extends StatefulWidget {
@ -29,7 +28,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
final _editCompanyKey = GlobalKey<FormState>();
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).company;
String getAppBarTitle(BuildContext context) => L10().company;
@override
Future<void> request(BuildContext context) async {
@ -55,17 +54,17 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
var _description;
var _website;
showFormDialog(I18N.of(context).edit,
showFormDialog(L10().edit,
key: _editCompanyKey,
actions: <Widget>[
FlatButton(
child: Text(I18N.of(context).cancel),
child: Text(L10().cancel),
onPressed: () {
Navigator.pop(context);
},
),
FlatButton(
child: Text(I18N.of(context).save),
child: Text(L10().save),
onPressed: () {
if (_editCompanyKey.currentState.validate()) {
_editCompanyKey.currentState.save();
@ -81,21 +80,21 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
],
fields: <Widget>[
StringField(
label: I18N.of(context).name,
label: L10().name,
initial: company.name,
onSaved: (value) {
_name = value;
},
),
StringField(
label: I18N.of(context).description,
label: L10().description,
initial: company.description,
onSaved: (value) {
_description = value;
},
),
StringField(
label: I18N.of(context).website,
label: L10().website,
initial: company.website,
allowEmpty: true,
onSaved: (value) {
@ -193,7 +192,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (company.notes.isNotEmpty) {
tiles.add(ListTile(
title: Text(I18N.of(context).notes),
title: Text(L10().notes),
leading: FaIcon(FontAwesomeIcons.stickyNote),
onTap: null,
));

View File

@ -2,21 +2,20 @@
import 'package:InvenTree/app_settings.dart';
import 'package:InvenTree/widget/snacks.dart';
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:one_context/one_context.dart';
Future<void> confirmationDialog(String title, String text, {String acceptText, String rejectText, Function onAccept, Function onReject}) async {
if (acceptText == null || acceptText.isEmpty) {
acceptText = I18N.of(OneContext().context).ok;
acceptText = L10().ok;
}
if (rejectText == null || rejectText.isEmpty) {
rejectText = I18N.of(OneContext().context).cancel;
rejectText = L10().cancel;
}
OneContext().showDialog(
@ -60,7 +59,7 @@ Future<void> confirmationDialog(String title, String text, {String acceptText, S
Future<void> showInfoDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.info, String info, Function onDismissed}) async {
if (info == null || info.isEmpty) {
info = I18N.of(context).info;
info = L10().info;
}
showDialog(
@ -87,7 +86,7 @@ Future<void> showInfoDialog(BuildContext context, String title, String descripti
Future<void> showErrorDialog(String title, String description, {IconData icon = FontAwesomeIcons.exclamationCircle, String error, Function onDismissed}) async {
if (error == null || error.isEmpty) {
error = I18N.of(OneContext().context).error;
error = L10().error;
}
OneContext().showDialog(
@ -113,7 +112,7 @@ Future<void> showErrorDialog(String title, String description, {IconData icon =
Future<void> showServerError(String title, String description) async {
if (title == null || title.isEmpty) {
title = I18N.of(OneContext().context).serverError;
title = L10().serverError;
}
// Play a sound
@ -127,12 +126,12 @@ Future<void> showServerError(String title, String description) async {
showSnackIcon(
title,
success: false,
actionText: I18N.of(OneContext().context).details,
actionText: L10().details,
onAction: () {
showErrorDialog(
title,
description,
error: I18N.of(OneContext().context).serverError,
error: L10().serverError,
icon: FontAwesomeIcons.server
);
}
@ -143,27 +142,27 @@ Future<void> showStatusCodeError(int status, {int expected = 200}) async {
BuildContext ctx = OneContext().context;
String msg = I18N.of(ctx).responseInvalid;
String msg = L10().responseInvalid;
String extra = "Server responded with status code ${status}";
switch (status) {
case 400:
msg = I18N.of(ctx).response400;
msg = L10().response400;
break;
case 401:
msg = I18N.of(ctx).response401;
msg = L10().response401;
break;
case 403:
msg = I18N.of(ctx).response403;
msg = L10().response403;
break;
case 404:
msg = I18N.of(ctx).response404;
msg = L10().response404;
break;
case 405:
msg = I18N.of(ctx).response405;
msg = L10().response405;
break;
case 429:
msg = I18N.of(ctx).response429;
msg = L10().response429;
break;
default:
break;
@ -180,7 +179,7 @@ Future<void> showTimeoutError(BuildContext context) async {
// Use OneContext as "sometimes" context is null here?
var ctx = OneContext().context;
await showServerError(I18N.of(ctx).timeout, I18N.of(ctx).noResponse);
await showServerError(L10().timeout, L10().noResponse);
}
void showFormDialog(String title, {String acceptText, String cancelText, GlobalKey<FormState> key, List<Widget> fields, List<Widget> actions, Function callback}) {
@ -190,11 +189,11 @@ void showFormDialog(String title, {String acceptText, String cancelText, GlobalK
var ctx = OneContext().context;
if (acceptText == null) {
acceptText = I18N.of(ctx).save;
acceptText = L10().save;
}
if (cancelText == null) {
cancelText = I18N.of(ctx).cancel;
cancelText = L10().cancel;
}
// Undefined actions = OK + Cancel

View File

@ -3,9 +3,7 @@ import 'package:InvenTree/barcode.dart';
import 'package:InvenTree/widget/company_list.dart';
import 'package:InvenTree/widget/search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/api.dart';
import 'package:InvenTree/l10.dart';
import 'package:InvenTree/widget/category_display.dart';
import 'package:InvenTree/widget/location_display.dart';
@ -118,28 +116,28 @@ class InvenTreeDrawer extends StatelessWidget {
width: 30,
),
title: Text(
I18N.of(context).appTitle,
L10().appTitle,
style: TextStyle(fontWeight: FontWeight.bold),
),
onTap: _home,
),
ListTile(
title: Text(I18N.of(context).scanBarcode),
title: Text(L10().scanBarcode),
onTap: _scan,
leading: FaIcon(FontAwesomeIcons.barcode),
),
ListTile(
title: Text(I18N.of(context).search),
title: Text(L10().search),
leading: FaIcon(FontAwesomeIcons.search),
onTap: _search,
),
ListTile(
title: Text(I18N.of(context).parts),
title: Text(L10().parts),
leading: Icon(Icons.category),
onTap: _showParts,
),
ListTile(
title: Text(I18N.of(context).stock),
title: Text(L10().stock),
leading: FaIcon(FontAwesomeIcons.boxes),
onTap: _showStock,
),
@ -161,7 +159,7 @@ class InvenTreeDrawer extends StatelessWidget {
),
*/
ListTile(
title: Text(I18N.of(context).settings),
title: Text(L10().settings),
leading: Icon(Icons.settings),
onTap: _settings,
),

View File

@ -4,7 +4,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart';
import 'package:one_context/one_context.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'dart:async';
import 'dart:io';
@ -52,7 +53,7 @@ class ImagePickerField extends FormField<File> {
onSaved: onSaved,
validator: (File img) {
if (required && (img == null)) {
return I18N.of(context).required;
return L10().required;
}
return null;
@ -67,13 +68,13 @@ class ImagePickerField extends FormField<File> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
child: Text(I18N.of(context).selectImage),
child: Text(L10().selectImage),
onPressed: () {
_selectFromGallery(state);
},
),
FlatButton(
child: Text(I18N.of(context).takePicture),
child: Text(L10().takePicture),
onPressed: () {
_selectFromCamera(state);
},
@ -82,7 +83,7 @@ class ImagePickerField extends FormField<File> {
),
);
return ListTile(
title: Text(I18N.of(context).selectImage),
title: Text(L10().selectImage),
);
}
);
@ -120,7 +121,7 @@ class StringField extends TextFormField {
enabled: isEnabled,
validator: (value) {
if (!allowEmpty && value.isEmpty) {
return I18N.of(OneContext().context).valueCannotBeEmpty;
return L10().valueCannotBeEmpty;
}
if (validator != null) {
@ -148,14 +149,12 @@ class QuantityField extends TextFormField {
keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
validator: (value) {
final ctx = OneContext().context;
if (value.isEmpty) return I18N.of(ctx).quantityEmpty;
if (value.isEmpty) return L10().quantityEmpty;
double quantity = double.tryParse(value);
if (quantity == null) return I18N.of(ctx).quantityInvalid;
if (quantity <= 0) return I18N.of(ctx).quantityPositive;
if (quantity == null) return L10().quantityInvalid;
if (quantity <= 0) return L10().quantityPositive;
if ((max != null) && (quantity > max)) return "Quantity must not exceed ${max}";
return null;

View File

@ -3,7 +3,7 @@ import 'package:InvenTree/widget/starred_parts.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'file:///C:/inventree-app/lib/l10.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -128,8 +128,8 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
// Tap to select / create a profile
if (_profile == null) {
return ListTile(
title: Text(I18N.of(context).profileNotSelected),
subtitle: Text(I18N.of(context).profileTapToCreate),
title: Text(L10().profileNotSelected),
subtitle: Text(L10().profileTapToCreate),
leading: FaIcon(FontAwesomeIcons.server),
trailing: FaIcon(
FontAwesomeIcons.user,
@ -144,7 +144,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
// Profile is selected ...
if (InvenTreeAPI().isConnecting()) {
return ListTile(
title: Text(I18N.of(context).serverConnecting),
title: Text(L10().serverConnecting),
subtitle: Text("${InvenTreeAPI().baseUrl}"),
leading: FaIcon(FontAwesomeIcons.server),
trailing: Spinner(
@ -157,7 +157,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
);
} else if (InvenTreeAPI().isConnected()) {
return ListTile(
title: Text(I18N.of(context).serverConnected),
title: Text(L10().serverConnected),
subtitle: Text("${InvenTreeAPI().baseUrl}"),
leading: FaIcon(FontAwesomeIcons.server),
trailing: FaIcon(
@ -170,7 +170,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
);
} else {
return ListTile(
title: Text(I18N.of(context).serverCouldNotConnect),
title: Text(L10().serverCouldNotConnect),
subtitle: Text("${_profile.server}"),
leading: FaIcon(FontAwesomeIcons.server),
trailing: FaIcon(
@ -198,12 +198,12 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
return Scaffold(
key: _homeKey,
appBar: AppBar(
title: Text(I18N.of(context).appTitle),
title: Text(L10().appTitle),
actions: <Widget>[
/*
IconButton(
icon: FaIcon(FontAwesomeIcons.search),
tooltip: I18N.of(context).search,
tooltip: L10().search,
onPressed: _searchParts,
),
*/
@ -224,10 +224,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.barcode),
tooltip: I18N.of(context).scanBarcode,
tooltip: L10().scanBarcode,
onPressed: () { _scan(context); },
),
Text(I18N.of(context).scanBarcode),
Text(L10().scanBarcode),
],
),
],
@ -240,10 +240,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.shapes),
tooltip: I18N.of(context).parts,
tooltip: L10().parts,
onPressed: () { _parts(context); },
),
Text(I18N.of(context).parts),
Text(L10().parts),
],
),
Column(
@ -251,10 +251,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
IconButton(
icon: new FaIcon(FontAwesomeIcons.search),
tooltip: I18N.of(context).searchParts,
tooltip: L10().searchParts,
onPressed: _searchParts,
),
Text(I18N.of(context).searchParts),
Text(L10().searchParts),
],
),
// TODO - Re-add starred parts link
@ -281,20 +281,20 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.boxes),
tooltip: I18N.of(context).stock,
tooltip: L10().stock,
onPressed: () { _stock(context); },
),
Text(I18N.of(context).stock),
Text(L10().stock),
],
),
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.search),
tooltip: I18N.of(context).searchStock,
tooltip: L10().searchStock,
onPressed: _searchStock,
),
Text(I18N.of(context).searchStock),
Text(L10().searchStock),
],
),
]

View File

@ -2,22 +2,20 @@ import 'package:InvenTree/api.dart';
import 'package:InvenTree/app_settings.dart';
import 'package:InvenTree/barcode.dart';
import 'package:InvenTree/inventree/stock.dart';
import 'package:InvenTree/preferences.dart';
import 'package:InvenTree/widget/progress.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:InvenTree/widget/fields.dart';
import 'package:InvenTree/widget/dialogs.dart';
import 'package:InvenTree/widget/search.dart';
import 'package:InvenTree/widget/snacks.dart';
import 'package:InvenTree/widget/stock_detail.dart';
import 'package:InvenTree/widget/paginator.dart';
import 'package:InvenTree/l10.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
class LocationDisplayWidget extends StatefulWidget {
@ -71,7 +69,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
tooltip: L10().edit,
onPressed: _editLocationDialog,
)
);
@ -97,7 +95,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
var _name;
var _description;
showFormDialog(I18N.of(context).editLocation,
showFormDialog(L10().editLocation,
key: _editLocationKey,
callback: () {
_editLocation({
@ -107,12 +105,12 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
},
fields: <Widget> [
StringField(
label: I18N.of(context).name,
label: L10().name,
initial: location.name,
onSaved: (value) => _name = value,
),
StringField(
label: I18N.of(context).description,
label: L10().description,
initial: location.description,
onSaved: (value) => _description = value,
)
@ -168,7 +166,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
if (location == null) {
return Card(
child: ListTile(
title: Text(I18N.of(context).stockTopLevel),
title: Text(L10().stockTopLevel),
)
);
} else {
@ -183,7 +181,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
if (includeActions) {
children.add(
ListTile(
title: Text(I18N.of(context).parentCategory),
title: Text(L10().parentCategory),
subtitle: Text("${location.parentpathstring}"),
leading: FaIcon(FontAwesomeIcons.levelUpAlt),
onTap: () {
@ -217,16 +215,16 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
items: <BottomNavigationBarItem> [
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.sitemap),
label: I18N.of(context).details,
label: L10().details,
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.boxes),
label: I18N.of(context).stock,
label: L10().stock,
),
// TODO - Add in actions when they are written...
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
label: I18N.of(context).actions,
label: L10().actions,
)
]
);
@ -273,7 +271,7 @@ List<Widget> detailTiles() {
locationDescriptionCard(),
ListTile(
title: Text(
I18N.of(context).sublocations,
L10().sublocations,
style: TextStyle(fontWeight: FontWeight.bold),
),
trailing: sublocations.length > 0 ? Text("${sublocations.length}") : null,
@ -286,8 +284,8 @@ List<Widget> detailTiles() {
tiles.add(SublocationList(_sublocations));
} else {
tiles.add(ListTile(
title: Text(I18N.of(context).sublocationNone),
subtitle: Text(I18N.of(context).sublocationNoneDetail)
title: Text(L10().sublocationNone),
subtitle: Text(L10().sublocationNoneDetail)
));
}
@ -305,9 +303,7 @@ List<Widget> detailTiles() {
// Scan items into location
tiles.add(
ListTile(
title: Text(I18N
.of(context)
.barcodeScanInItems),
title: Text(L10().barcodeScanInItems),
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
trailing: FaIcon(FontAwesomeIcons.qrcode),
onTap: () {

View File

@ -2,8 +2,8 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:InvenTree/l10.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaginatedSearchWidget extends StatelessWidget {
@ -36,7 +36,7 @@ class PaginatedSearchWidget extends StatelessWidget {
}
},
decoration: InputDecoration(
hintText: I18N.of(context).search,
hintText: L10().search,
),
),
trailing: Text(
@ -57,7 +57,7 @@ class NoResultsWidget extends StatelessWidget {
Widget build(BuildContext context) {
return ListTile(
title: Text(I18N.of(context).noResults),
title: Text(L10().noResults),
subtitle: Text(description),
leading: FaIcon(FontAwesomeIcons.exclamationCircle),
);

View File

@ -1,14 +1,12 @@
import 'dart:io';
import 'package:InvenTree/inventree/stock.dart';
import 'package:InvenTree/widget/part_notes.dart';
import 'package:InvenTree/widget/progress.dart';
import 'package:InvenTree/widget/snacks.dart';
import 'package:InvenTree/widget/stock_detail.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:InvenTree/inventree/part.dart';
@ -39,7 +37,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
final _editPartKey = GlobalKey<FormState>();
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).partDetails;
String getAppBarTitle(BuildContext context) => L10().partDetails;
@override
List<Widget> getAppBarActions(BuildContext context) {
@ -59,7 +57,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
tooltip: L10().edit,
onPressed: _editPartDialog,
)
);
@ -127,7 +125,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
var _keywords;
var _link;
showFormDialog(I18N.of(context).editPart,
showFormDialog(L10().editPart,
key: _editPartKey,
callback: () {
_savePart({
@ -140,29 +138,29 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
},
fields: <Widget>[
StringField(
label: I18N.of(context).name,
label: L10().name,
initial: part.name,
onSaved: (value) => _name = value,
),
StringField(
label: I18N.of(context).description,
label: L10().description,
initial: part.description,
onSaved: (value) => _description = value,
),
StringField(
label: I18N.of(context).internalPartNumber,
label: L10().internalPartNumber,
initial: part.IPN,
allowEmpty: true,
onSaved: (value) => _ipn = value,
),
StringField(
label: I18N.of(context).keywords,
label: L10().keywords,
initial: part.keywords,
allowEmpty: true,
onSaved: (value) => _keywords = value,
),
StringField(
label: I18N.of(context).link,
label: L10().link,
initial: part.link,
allowEmpty: true,
onSaved: (value) => _link = value
@ -216,7 +214,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
if (part.categoryName != null && part.categoryName.isNotEmpty) {
tiles.add(
ListTile(
title: Text(I18N.of(context).partCategory),
title: Text(L10().partCategory),
subtitle: Text("${part.categoryName}"),
leading: FaIcon(FontAwesomeIcons.sitemap),
onTap: () {
@ -232,8 +230,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
} else {
tiles.add(
ListTile(
title: Text(I18N.of(context).partCategory),
subtitle: Text(I18N.of(context).partCategoryTopLevel),
title: Text(L10().partCategory),
subtitle: Text(L10().partCategoryTopLevel),
leading: FaIcon(FontAwesomeIcons.sitemap),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
@ -245,7 +243,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
// Stock information
tiles.add(
ListTile(
title: Text(I18N.of(context).stock),
title: Text(L10().stock),
leading: FaIcon(FontAwesomeIcons.boxes),
trailing: Text("${part.inStockString}"),
onTap: () {
@ -261,7 +259,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
if (part.supplier_count > 0) {
tiles.add(
ListTile(
title: Text(I18N.of(context).suppliers),
title: Text(L10().suppliers),
leading: FaIcon(FontAwesomeIcons.industry),
trailing: Text("${part.supplier_count}"),
)
@ -289,7 +287,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
if (false && part.isAssembly) {
tiles.add(ListTile(
title: Text(I18N.of(context).billOfMaterials),
title: Text(L10().billOfMaterials),
leading: FaIcon(FontAwesomeIcons.thList),
trailing: Text("${part.bomItemCount}"),
onTap: null,
@ -298,7 +296,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
tiles.add(
ListTile(
title: Text(I18N.of(context).building),
title: Text(L10().building),
leading: FaIcon(FontAwesomeIcons.tools),
trailing: Text("${part.building}"),
onTap: null,
@ -344,7 +342,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
// TODO - Add request tests?
if (false && part.isTrackable) {
tiles.add(ListTile(
title: Text(I18N.of(context).testsRequired),
title: Text(L10().testsRequired),
leading: FaIcon(FontAwesomeIcons.tasks),
trailing: Text("${part.testTemplateCount}"),
onTap: null,
@ -356,7 +354,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
if (part.notes.isNotEmpty) {
tiles.add(
ListTile(
title: Text(I18N.of(context).notes),
title: Text(L10().notes),
leading: FaIcon(FontAwesomeIcons.stickyNote),
trailing: Text(""),
onTap: () {
@ -382,7 +380,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
tiles.add(
ListTile(
title: Text(
I18N.of(context).stockItems,
L10().stockItems,
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: part.stockItems.isEmpty ? Text("No stock items available") : null,
@ -408,7 +406,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
tiles.add(
ListTile(
title: Text(I18N.of(context).stockItemCreate),
title: Text(L10().stockItemCreate),
leading: FaIcon(FontAwesomeIcons.box),
onTap: null,
)
@ -463,17 +461,17 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
items: <BottomNavigationBarItem> [
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.infoCircle),
label: I18N.of(context).details,
label: L10().details,
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.boxes),
label: I18N.of(context).stock
label: L10().stock
),
// TODO - Add part actions
/*
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
label: I18N.of(context).actions,
label: L10().actions,
),
*/
]

View File

@ -1,11 +1,8 @@
import 'package:InvenTree/inventree/part.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
class PartNotesWidget extends StatefulWidget {
@ -26,7 +23,7 @@ class _PartNotesState extends RefreshableState<PartNotesWidget> {
_PartNotesState(this.part);
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).partNotes;
String getAppBarTitle(BuildContext context) => L10().partNotes;
@override
Widget getBody(BuildContext context) {

View File

@ -6,10 +6,10 @@ import 'package:InvenTree/widget/stock_detail.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:InvenTree/inventree/part.dart';
import 'package:InvenTree/inventree/stock.dart';
import 'package:one_context/one_context.dart';
import '../api.dart';
@ -36,7 +36,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> {
}
@override
String get searchFieldLabel => I18N.of(context).searchParts;
String get searchFieldLabel => L10().searchParts;
// List of part results
List<InvenTreePart> partResults = [];
@ -79,7 +79,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> {
_searching = false;
showSnackIcon(
"${partResults.length} ${I18N.of(OneContext().context).results}",
"${partResults.length} ${L10().results}",
success: partResults.length > 0,
icon: FontAwesomeIcons.pollH,
);
@ -157,21 +157,21 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> {
if (query.length == 0) {
return ListTile(
title: Text(I18N.of(context).queryEnter)
title: Text(L10().queryEnter)
);
}
if (query.length < 3) {
return ListTile(
title: Text(I18N.of(context).queryShort),
subtitle: Text(I18N.of(context).queryShortDetail)
title: Text(L10().queryShort),
subtitle: Text(L10().queryShortDetail)
);
}
if (partResults.length == 0) {
return ListTile(
title: Text(I18N.of(context).noResults),
subtitle: Text(I18N.of(context).queryNoResults + " '${query}'")
title: Text(L10().noResults),
subtitle: Text(L10().queryNoResults + " '${query}'")
);
}
@ -221,7 +221,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> {
}
@override
String get searchFieldLabel => I18N.of(context).searchStock;
String get searchFieldLabel => L10().searchStock;
// List of StockItem results
List<InvenTreeStockItem> itemResults = [];
@ -263,7 +263,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> {
_searching = false;
showSnackIcon(
"${itemResults.length} ${I18N.of(OneContext().context).results}",
"${itemResults.length} ${L10().results}",
success: itemResults.length > 0,
icon: FontAwesomeIcons.pollH,
);
@ -340,21 +340,21 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> {
if (query.length == 0) {
return ListTile(
title: Text(I18N.of(context).queryEnter)
title: Text(L10().queryEnter)
);
}
if (query.length < 3) {
return ListTile(
title: Text(I18N.of(context).queryShort),
subtitle: Text(I18N.of(context).queryShortDetail)
title: Text(L10().queryShort),
subtitle: Text(L10().queryShortDetail)
);
}
if (itemResults.length == 0) {
return ListTile(
title: Text(I18N.of(context).noResults),
subtitle: Text(I18N.of(context).queryNoResults + " '${query}'")
title: Text(L10().noResults),
subtitle: Text(L10().queryNoResults + " '${query}'")
);
}

View File

@ -12,7 +12,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:one_context/one_context.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
void showSnackIcon(String text, {IconData icon, Function onAction, bool success, String actionText}) {
@ -44,7 +45,7 @@ void showSnackIcon(String text, {IconData icon, Function onAction, bool success,
if (actionText == null) {
// Default action text
actionText = I18N.of(OneContext().context).details;
actionText = L10().details;
}
action = SnackBarAction(

View File

@ -7,7 +7,7 @@ import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import '../api.dart';
@ -26,7 +26,7 @@ class _StarredPartState extends RefreshableState<StarredPartWidget> {
List<InvenTreePart> starredParts = [];
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).partsStarred;
String getAppBarTitle(BuildContext context) => L10().partsStarred;
@override
Future<void> request(BuildContext context) async {
@ -77,8 +77,8 @@ class _StarredPartState extends RefreshableState<StarredPartWidget> {
return ListView(
children: [
ListTile(
title: Text(I18N.of(context).partsNone),
subtitle: Text(I18N.of(context).partsStarredNone)
title: Text(L10().partsNone),
subtitle: Text(L10().partsStarredNone)
)
],
);

View File

@ -16,7 +16,7 @@ import 'package:InvenTree/widget/stock_notes.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:InvenTree/api.dart';
@ -37,7 +37,7 @@ class StockDetailWidget extends StatefulWidget {
class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).stockItem;
String getAppBarTitle(BuildContext context) => L10().stockItem;
final TextEditingController _quantityController = TextEditingController();
final TextEditingController _notesController = TextEditingController();
@ -62,7 +62,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
/*
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
tooltip: L10().edit,
onPressed: _editPartDialog,
)
*/
@ -117,7 +117,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.clear();
_notesController.clear();
showFormDialog( I18N.of(context).addStock,
showFormDialog( L10().addStock,
key: _addStockKey,
callback: () {
_addStock();
@ -125,12 +125,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
fields: <Widget> [
Text("Current stock: ${item.quantity}"),
QuantityField(
label: I18N.of(context).addStock,
label: L10().addStock,
controller: _quantityController,
),
TextFormField(
decoration: InputDecoration(
labelText: I18N.of(context).notes,
labelText: L10().notes,
),
controller: _notesController,
)
@ -163,7 +163,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.clear();
_notesController.clear();
showFormDialog(I18N.of(context).removeStock,
showFormDialog(L10().removeStock,
key: _removeStockKey,
callback: () {
_removeStock();
@ -171,13 +171,13 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
fields: <Widget>[
Text("Current stock: ${item.quantity}"),
QuantityField(
label: I18N.of(context).removeStock,
label: L10().removeStock,
controller: _quantityController,
max: item.quantity,
),
TextFormField(
decoration: InputDecoration(
labelText: I18N.of(context).notes,
labelText: L10().notes,
),
controller: _notesController,
),
@ -202,21 +202,21 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.text = item.quantityString;
_notesController.clear();
showFormDialog(I18N.of(context).countStock,
showFormDialog(L10().countStock,
key: _countStockKey,
callback: () {
_countStock();
},
acceptText: I18N.of(context).count,
acceptText: L10().count,
fields: <Widget> [
QuantityField(
label: I18N.of(context).countStock,
label: L10().countStock,
hint: "${item.quantityString}",
controller: _quantityController,
),
TextFormField(
decoration: InputDecoration(
labelText: I18N.of(context).notes,
labelText: L10().notes,
),
controller: _notesController,
)
@ -231,12 +231,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (result) {
showSnackIcon(
I18N.of(context).stockItemUpdateSuccess,
L10().stockItemUpdateSuccess,
success: true
);
} else {
showSnackIcon(
I18N.of(context).stockItemUpdateFailure,
L10().stockItemUpdateFailure,
success: false,
);
}
@ -271,14 +271,14 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.text = "${item.quantityString}";
showFormDialog(I18N.of(context).transferStock,
showFormDialog(L10().transferStock,
key: _moveStockKey,
callback: () {
_transferStock(context, selectedLocation);
},
fields: <Widget>[
QuantityField(
label: I18N.of(context).quantity,
label: L10().quantity,
controller: _quantityController,
max: item.quantity,
),
@ -304,7 +304,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
},
validator: (value) {
if (selectedLocation == null) {
return I18N.of(context).selectLocation;
return L10().selectLocation;
}
return null;
@ -373,7 +373,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (item.isSerialized()) {
tiles.add(
ListTile(
title: Text(I18N.of(context).serialNumber),
title: Text(L10().serialNumber),
leading: FaIcon(FontAwesomeIcons.hashtag),
trailing: Text("${item.serialNumber}"),
)
@ -381,7 +381,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
} else {
tiles.add(
ListTile(
title: Text(I18N.of(context).quantity),
title: Text(L10().quantity),
leading: FaIcon(FontAwesomeIcons.cubes),
trailing: Text("${item.quantityString}"),
)
@ -392,7 +392,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if ((item.locationId > 0) && (item.locationName != null) && (item.locationName.isNotEmpty)) {
tiles.add(
ListTile(
title: Text(I18N.of(context).stockLocation),
title: Text(L10().stockLocation),
subtitle: Text("${item.locationPathString}"),
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
onTap: () {
@ -408,9 +408,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
} else {
tiles.add(
ListTile(
title: Text(I18N.of(context).stockLocation),
title: Text(L10().stockLocation),
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
subtitle: Text(I18N.of(context).locationNotSet),
subtitle: Text(L10().locationNotSet),
)
);
}
@ -445,7 +445,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if ((item.testResultCount > 0) || (part != null && part.isTrackable)) {
tiles.add(
ListTile(
title: Text(I18N.of(context).testResults),
title: Text(L10().testResults),
leading: FaIcon(FontAwesomeIcons.tasks),
trailing: Text("${item.testResultCount}"),
onTap: () {
@ -465,7 +465,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (false && item.trackingItemCount > 0) {
tiles.add(
ListTile(
title: Text(I18N.of(context).history),
title: Text(L10().history),
leading: FaIcon(FontAwesomeIcons.history),
trailing: Text("${item.trackingItemCount}"),
onTap: () {
@ -481,7 +481,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (item.notes.isNotEmpty) {
tiles.add(
ListTile(
title: Text(I18N.of(context).notes),
title: Text(L10().notes),
leading: FaIcon(FontAwesomeIcons.stickyNote),
trailing: Text(""),
onTap: () {
@ -508,14 +508,14 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (!InvenTreeAPI().checkPermission('stock', 'change')) {
tiles.add(
ListTile(
title: Text(I18N.of(context).permissionRequired),
title: Text(L10().permissionRequired),
leading: FaIcon(FontAwesomeIcons.userTimes)
)
);
tiles.add(
ListTile(
subtitle: Text(I18N.of(context).permissionAccountDenied),
subtitle: Text(L10().permissionAccountDenied),
)
);
@ -525,7 +525,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (!item.isSerialized()) {
tiles.add(
ListTile(
title: Text(I18N.of(context).countStock),
title: Text(L10().countStock),
leading: FaIcon(FontAwesomeIcons.checkCircle),
onTap: _countStockDialog,
trailing: Text(item.quantityString),
@ -534,7 +534,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
tiles.add(
ListTile(
title: Text(I18N.of(context).removeStock),
title: Text(L10().removeStock),
leading: FaIcon(FontAwesomeIcons.minusCircle),
onTap: _removeStockDialog,
)
@ -542,7 +542,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
tiles.add(
ListTile(
title: Text(I18N.of(context).addStock),
title: Text(L10().addStock),
leading: FaIcon(FontAwesomeIcons.plusCircle),
onTap: _addStockDialog,
)
@ -551,7 +551,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
tiles.add(
ListTile(
title: Text(I18N.of(context).transferStock),
title: Text(L10().transferStock),
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
onTap: _transferStockDialog,
)
@ -560,7 +560,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
// Scan item into a location
tiles.add(
ListTile(
title: Text(I18N.of(context).scanIntoLocation),
title: Text(L10().scanIntoLocation),
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
trailing: FaIcon(FontAwesomeIcons.qrcode),
onTap: () {
@ -578,7 +578,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
if (item.uid.isEmpty) {
tiles.add(
ListTile(
title: Text(I18N.of(context).barcodeAssign),
title: Text(L10().barcodeAssign),
leading: FaIcon(FontAwesomeIcons.barcode),
trailing: FaIcon(FontAwesomeIcons.qrcode),
onTap: () {
@ -594,7 +594,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
} else {
tiles.add(
ListTile(
title: Text(I18N.of(context).barcodeUnassign),
title: Text(L10().barcodeUnassign),
leading: FaIcon(FontAwesomeIcons.barcode),
onTap: () {
_unassignBarcode(context);
@ -614,11 +614,11 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
items: <BottomNavigationBarItem> [
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.infoCircle),
title: Text(I18N.of(context).details),
title: Text(L10().details),
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
title: Text(I18N.of(context).actions),
title: Text(L10().actions),
),
]
);

View File

@ -7,16 +7,15 @@ import 'package:InvenTree/widget/fields.dart';
import 'package:InvenTree/widget/progress.dart';
import 'package:InvenTree/widget/snacks.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart';
class StockItemTestResultsWidget extends StatefulWidget {
@ -34,7 +33,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
final _addResultKey = GlobalKey<FormState>();
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).testResults;
String getAppBarTitle(BuildContext context) => L10().testResults;
@override
Future<void> request(BuildContext context) async {
@ -78,38 +77,38 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
},
fields: <Widget>[
StringField(
label: I18N.of(context).testName,
label: L10().testName,
initial: name,
isEnabled: nameIsEditable,
onSaved: (value) => _name = value,
),
CheckBoxField(
label: I18N.of(context).result,
hint: I18N.of(context).testPassedOrFailed,
label: L10().result,
hint: L10().testPassedOrFailed,
initial: true,
onSaved: (value) => _result = value,
),
StringField(
label: I18N.of(context).value,
label: L10().value,
initial: value,
allowEmpty: true,
onSaved: (value) => _value = value,
validator: (String value) {
if (valueRequired && (value == null || value.isEmpty)) {
return I18N.of(context).valueRequired;
return L10().valueRequired;
}
return null;
},
),
ImagePickerField(
context,
label: I18N.of(context).attachImage,
label: L10().attachImage,
required: attachmentRequired,
onSaved: (attachment) => _attachment = attachment,
),
StringField(
allowEmpty: true,
label: I18N.of(context).notes,
label: L10().notes,
onSaved: (value) => _notes = value,
),
]
@ -178,7 +177,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
tiles.add(
ListTile(
title: Text(I18N.of(context).testResults,
title: Text(L10().testResults,
style: TextStyle(fontWeight: FontWeight.bold)
)
)
@ -193,8 +192,8 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
if (results.length == 0) {
tiles.add(ListTile(
title: Text(I18N.of(context).testResultNone),
subtitle: Text(I18N.of(context).testResultNoneDetail),
title: Text(L10().testResultNone),
subtitle: Text(L10().testResultNoneDetail),
));
return tiles;
@ -254,7 +253,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
if (tiles.isEmpty) {
tiles.add(ListTile(
title: Text(I18N.of(context).testResultNone),
title: Text(L10().testResultNone),
));
}
@ -279,7 +278,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
buttons.add(SpeedDialChild(
child: Icon(FontAwesomeIcons.plusCircle),
label: I18N.of(context).testResultAdd,
label: L10().testResultAdd,
onTap: () {
addTestResult();
},

View File

@ -1,11 +1,9 @@
import 'package:InvenTree/inventree/stock.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
class StockNotesWidget extends StatefulWidget {
@ -26,7 +24,7 @@ class _StockNotesState extends RefreshableState<StockNotesWidget> {
_StockNotesState(this.item);
@override
String getAppBarTitle(BuildContext context) => I18N.of(context).stockItemNotes;
String getAppBarTitle(BuildContext context) => L10().stockItemNotes;
@override
Widget getBody(BuildContext context) {