2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

More code cleanup

This commit is contained in:
Oliver 2021-08-02 21:53:57 +10:00
parent 68859b3d2e
commit d47a8db289
7 changed files with 15 additions and 50 deletions

View File

@ -18,7 +18,7 @@ import 'package:inventree/user_profile.dart';
import 'package:inventree/widget/snacks.dart'; import 'package:inventree/widget/snacks.dart';
/** /*
* Class representing an API response from the server * Class representing an API response from the server
*/ */
class APIResponse { class APIResponse {
@ -38,7 +38,7 @@ class APIResponse {
} }
/** /*
* Custom FileService for caching network images * Custom FileService for caching network images
* Requires a custom badCertificateCallback, * Requires a custom badCertificateCallback,
* so we can accept "dodgy" certificates * so we can accept "dodgy" certificates
@ -82,7 +82,7 @@ class InvenTreeFileService extends FileService {
} }
} }
/** /*
* InvenTree API - Access to the InvenTree REST interface. * InvenTree API - Access to the InvenTree REST interface.
* *
* InvenTree implements token-based authentication, which is * InvenTree implements token-based authentication, which is
@ -201,7 +201,7 @@ class InvenTreeAPI {
InvenTreeAPI._internal(); InvenTreeAPI._internal();
/** /*
* Connect to the remote InvenTree server: * Connect to the remote InvenTree server:
* *
* - Check that the InvenTree server exists * - Check that the InvenTree server exists
@ -502,7 +502,7 @@ class InvenTreeAPI {
return response; return response;
} }
/** /*
* Perform a HTTP OPTIONS request, * Perform a HTTP OPTIONS request,
* to get the available fields at a given endpoint. * to get the available fields at a given endpoint.
* We send this with the currently selected "locale", * We send this with the currently selected "locale",
@ -523,7 +523,7 @@ class InvenTreeAPI {
return completeRequest(request); return completeRequest(request);
} }
/** /*
* Perform a HTTP POST request * Perform a HTTP POST request
* Returns a json object (or null if unsuccessful) * Returns a json object (or null if unsuccessful)
*/ */
@ -572,7 +572,7 @@ class InvenTreeAPI {
return client; return client;
} }
/** /*
* Initiate a HTTP request to the server * Initiate a HTTP request to the server
* *
* @param url is the API endpoint * @param url is the API endpoint
@ -641,7 +641,7 @@ class InvenTreeAPI {
} }
/** /*
* Complete an API request, and return an APIResponse object * Complete an API request, and return an APIResponse object
*/ */
Future<APIResponse> completeRequest(HttpClientRequest request, {String? data, int? statusCode}) async { Future<APIResponse> completeRequest(HttpClientRequest request, {String? data, int? statusCode}) async {
@ -701,7 +701,7 @@ class InvenTreeAPI {
} }
/** /*
* Convert a HttpClientResponse response object to JSON * Convert a HttpClientResponse response object to JSON
*/ */
dynamic responseToJson(HttpClientResponse response) async { dynamic responseToJson(HttpClientResponse response) async {
@ -737,7 +737,7 @@ class InvenTreeAPI {
} }
/** /*
* Perform a HTTP GET request * Perform a HTTP GET request
* Returns a json object (or null if did not complete) * Returns a json object (or null if did not complete)
*/ */
@ -786,7 +786,7 @@ class InvenTreeAPI {
static String get staticThumb => "/static/img/blank_image.thumbnail.png"; static String get staticThumb => "/static/img/blank_image.thumbnail.png";
/** /*
* Load image from the InvenTree server, * Load image from the InvenTree server,
* or from local cache (if it has been cached!) * or from local cache (if it has been cached!)
*/ */

View File

@ -26,7 +26,7 @@ class InvenTreePageResponse {
List<InvenTreeModel> results = []; List<InvenTreeModel> results = [];
} }
/** /*
* The InvenTreeModel class provides a base-level object * The InvenTreeModel class provides a base-level object
* for interacting with InvenTree data. * for interacting with InvenTree data.
*/ */
@ -105,12 +105,9 @@ class InvenTreeModel {
void openLink() async { void openLink() async {
if (link.isNotEmpty) { if (link.isNotEmpty) {
print("Opening link: ${link}");
if (await canLaunch(link)) { if (await canLaunch(link)) {
await launch(link); await launch(link);
} else {
// TODO
} }
} }
} }

View File

@ -320,7 +320,7 @@ class InvenTreeStockItem extends InvenTreeModel {
return img; return img;
} }
/** /*
* Return the Part thumbnail for this stock item. * Return the Part thumbnail for this stock item.
*/ */
String get partThumbnail { String get partThumbnail {

View File

@ -326,7 +326,7 @@ class SubcategoryList extends StatelessWidget {
} }
/** /*
* Widget for displaying a list of Part objects within a PartCategory display. * Widget for displaying a list of Part objects within a PartCategory display.
* *
* Uses server-side pagination for snappy results * Uses server-side pagination for snappy results

View File

@ -1,8 +1,6 @@
import 'package:inventree/api.dart'; import 'package:inventree/api.dart';
import 'package:inventree/inventree/company.dart'; import 'package:inventree/inventree/company.dart';
import 'package:inventree/widget/dialogs.dart';
import 'package:inventree/widget/fields.dart';
import 'package:inventree/widget/refreshable_state.dart'; import 'package:inventree/widget/refreshable_state.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

View File

@ -384,7 +384,7 @@ class SublocationList extends StatelessWidget {
} }
} }
/** /*
* Widget for displaying a list of stock items within a stock location. * Widget for displaying a list of stock items within a stock location.
* *
* Users server-side pagination for snappy results * Users server-side pagination for snappy results

View File

@ -35,8 +35,6 @@ class PartDetailWidget extends StatefulWidget {
class _PartDisplayState extends RefreshableState<PartDetailWidget> { class _PartDisplayState extends RefreshableState<PartDetailWidget> {
final _editImageKey = GlobalKey<FormState>();
@override @override
String getAppBarTitle(BuildContext context) => L10().partDetails; String getAppBarTitle(BuildContext context) => L10().partDetails;
@ -102,34 +100,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
} }
} }
/**
* Upload image for this Part.
* Show a SnackBar with upload result.
*/
void _uploadImage(File? image) async {
if (image == null) {
return;
}
final result = await part.uploadImage(image);
if (result) {
showSnackIcon(
L10().imageUploadSuccess,
success: true
);
refresh();
} else {
showSnackIcon(
L10().imageUploadFailure,
success: false,
);
}
}
void _editPartDialog(BuildContext context) { void _editPartDialog(BuildContext context) {
launchApiForm( launchApiForm(