mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-18 13:15:31 +00:00
Update package versions and refactor accordingly
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:InvenTree/app_settings.dart';
|
||||
import 'package:InvenTree/widget/dialogs.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';
|
||||
@ -43,7 +43,7 @@ class BarcodeHandler {
|
||||
final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
|
||||
if (en) {
|
||||
AudioCache player = AudioCache();
|
||||
final player = AudioCache();
|
||||
player.play("sounds/barcode_scan.mp3");
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ class BarcodeHandler {
|
||||
final bool en = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
|
||||
if (en) {
|
||||
AudioCache player = AudioCache();
|
||||
final player = AudioCache();
|
||||
player.play("sounds/barcode_error.mp3");
|
||||
}
|
||||
}
|
||||
@ -223,7 +223,7 @@ class BarcodeScanHandler extends BarcodeHandler {
|
||||
onAction: () {
|
||||
showDialog(
|
||||
context: _context,
|
||||
child: SimpleDialog(
|
||||
builder: (BuildContext context) => SimpleDialog(
|
||||
title: Text(L10().unknownResponse),
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
|
@ -7,7 +7,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:one_context/one_context.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
// import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
|
@ -301,6 +301,10 @@ class InvenTreePart extends InvenTreeModel {
|
||||
return img.isNotEmpty ? img : InvenTreeAPI.staticThumb;
|
||||
}
|
||||
|
||||
void uploadImage(File image) async {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Return the "starred" status of this part
|
||||
bool get starred => jsondata['starred'] as bool ?? false;
|
||||
|
||||
|
2
lib/l10n
2
lib/l10n
Submodule lib/l10n updated: 55e409cf7d...f00018125f
@ -5,8 +5,6 @@ import 'package:InvenTree/inventree/sentry.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'file:///C:/inventree-app/lib/l10.dart';
|
||||
|
||||
import 'package:InvenTree/widget/home.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
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';
|
||||
@ -64,7 +64,7 @@ Future<void> showInfoDialog(BuildContext context, String title, String descripti
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
child: SimpleDialog(
|
||||
builder: (BuildContext context) => SimpleDialog(
|
||||
title: ListTile(
|
||||
title: Text(info),
|
||||
leading: FaIcon(icon),
|
||||
@ -119,7 +119,7 @@ Future<void> showServerError(String title, String description) async {
|
||||
final bool tones = await InvenTreeSettingsManager().getValue("serverSounds", true) as bool;
|
||||
|
||||
if (tones) {
|
||||
AudioCache player = AudioCache();
|
||||
final player = AudioCache();
|
||||
player.play("sounds/server_error.mp3");
|
||||
}
|
||||
|
||||
|
@ -28,24 +28,28 @@ class ImagePickerField extends FormField<File> {
|
||||
}
|
||||
|
||||
static Future<void> _getImageFromGallery(FormFieldState<File> field) async {
|
||||
|
||||
File image;
|
||||
|
||||
await ImagePicker.pickImage(source: ImageSource.gallery).then((File img) {
|
||||
image = img;
|
||||
});
|
||||
|
||||
field.didChange(image);
|
||||
final picker = ImagePicker();
|
||||
|
||||
final pickedImage = await picker.getImage(source: ImageSource.gallery);
|
||||
|
||||
if (pickedImage != null)
|
||||
{
|
||||
field.didChange(File(pickedImage.path));
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _getImageFromCamera(FormFieldState<File> field) async {
|
||||
File image;
|
||||
|
||||
await ImagePicker.pickImage(source: ImageSource.camera).then((File img) {
|
||||
image = img;
|
||||
});
|
||||
final picker = ImagePicker();
|
||||
|
||||
final pickedImage = await picker.getImage(source: ImageSource.camera);
|
||||
|
||||
if (pickedImage != null)
|
||||
{
|
||||
field.didChange(File(pickedImage.path));
|
||||
}
|
||||
|
||||
field.didChange(image);
|
||||
}
|
||||
|
||||
ImagePickerField(BuildContext context, {String label = "Attach Image", Function onSaved, bool required = false}) :
|
||||
|
@ -34,6 +34,7 @@ class PartDetailWidget extends StatefulWidget {
|
||||
|
||||
class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
final _editImageKey = GlobalKey<FormState>();
|
||||
final _editPartKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
@ -116,6 +117,39 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
refresh();
|
||||
}
|
||||
|
||||
void _uploadImage(File image) async {
|
||||
|
||||
print("Uploading image...");
|
||||
await part.uploadImage(image);
|
||||
print("Done");
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void _selectImage() {
|
||||
|
||||
File _attachment;
|
||||
|
||||
if (!InvenTreeAPI().checkPermission('part', 'change')) {
|
||||
return;
|
||||
}
|
||||
|
||||
showFormDialog(L10().selectImage,
|
||||
key: _editImageKey,
|
||||
callback: () {
|
||||
_uploadImage(_attachment);
|
||||
},
|
||||
fields: <Widget>[
|
||||
ImagePickerField(
|
||||
context,
|
||||
label: L10().attachImage,
|
||||
required: true,
|
||||
onSaved: (attachment) => _attachment = attachment,
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
void _editPartDialog() {
|
||||
|
||||
// Values which can be edited
|
||||
@ -189,6 +223,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
MaterialPageRoute(builder: (context) => FullScreenWidget(part.fullname, part.image))
|
||||
);
|
||||
}),
|
||||
onLongPress: _selectImage,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user