From d47a8db28942630b33dc4ecf5cd6f788672e7645 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 2 Aug 2021 21:53:57 +1000 Subject: [PATCH] More code cleanup --- lib/api.dart | 22 +++++++++++----------- lib/inventree/model.dart | 5 +---- lib/inventree/stock.dart | 2 +- lib/widget/category_display.dart | 2 +- lib/widget/company_detail.dart | 2 -- lib/widget/location_display.dart | 2 +- lib/widget/part_detail.dart | 30 ------------------------------ 7 files changed, 15 insertions(+), 50 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 843cfeb4..0f94c3ff 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -18,7 +18,7 @@ import 'package:inventree/user_profile.dart'; import 'package:inventree/widget/snacks.dart'; -/** +/* * Class representing an API response from the server */ class APIResponse { @@ -38,7 +38,7 @@ class APIResponse { } -/** +/* * Custom FileService for caching network images * Requires a custom badCertificateCallback, * so we can accept "dodgy" certificates @@ -82,7 +82,7 @@ class InvenTreeFileService extends FileService { } } -/** +/* * InvenTree API - Access to the InvenTree REST interface. * * InvenTree implements token-based authentication, which is @@ -201,7 +201,7 @@ class InvenTreeAPI { InvenTreeAPI._internal(); - /** + /* * Connect to the remote InvenTree server: * * - Check that the InvenTree server exists @@ -502,7 +502,7 @@ class InvenTreeAPI { return response; } - /** + /* * Perform a HTTP OPTIONS request, * to get the available fields at a given endpoint. * We send this with the currently selected "locale", @@ -523,7 +523,7 @@ class InvenTreeAPI { return completeRequest(request); } - /** + /* * Perform a HTTP POST request * Returns a json object (or null if unsuccessful) */ @@ -572,7 +572,7 @@ class InvenTreeAPI { return client; } - /** + /* * Initiate a HTTP request to the server * * @param url is the API endpoint @@ -641,7 +641,7 @@ class InvenTreeAPI { } - /** + /* * Complete an API request, and return an APIResponse object */ Future completeRequest(HttpClientRequest request, {String? data, int? statusCode}) async { @@ -701,7 +701,7 @@ class InvenTreeAPI { } - /** + /* * Convert a HttpClientResponse response object to JSON */ dynamic responseToJson(HttpClientResponse response) async { @@ -737,7 +737,7 @@ class InvenTreeAPI { } - /** + /* * Perform a HTTP GET request * 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"; - /** + /* * Load image from the InvenTree server, * or from local cache (if it has been cached!) */ diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index 62d2fae0..581402d9 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -26,7 +26,7 @@ class InvenTreePageResponse { List results = []; } -/** +/* * The InvenTreeModel class provides a base-level object * for interacting with InvenTree data. */ @@ -105,12 +105,9 @@ class InvenTreeModel { void openLink() async { if (link.isNotEmpty) { - print("Opening link: ${link}"); if (await canLaunch(link)) { await launch(link); - } else { - // TODO } } } diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 1b94a97d..c0b54b9c 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -320,7 +320,7 @@ class InvenTreeStockItem extends InvenTreeModel { return img; } - /** + /* * Return the Part thumbnail for this stock item. */ String get partThumbnail { diff --git a/lib/widget/category_display.dart b/lib/widget/category_display.dart index 83fbaced..e6da65ae 100644 --- a/lib/widget/category_display.dart +++ b/lib/widget/category_display.dart @@ -326,7 +326,7 @@ class SubcategoryList extends StatelessWidget { } -/** +/* * Widget for displaying a list of Part objects within a PartCategory display. * * Uses server-side pagination for snappy results diff --git a/lib/widget/company_detail.dart b/lib/widget/company_detail.dart index 123c9072..79b49c1c 100644 --- a/lib/widget/company_detail.dart +++ b/lib/widget/company_detail.dart @@ -1,8 +1,6 @@ import 'package:inventree/api.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:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index 9f91276f..233d0c3e 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -384,7 +384,7 @@ class SublocationList extends StatelessWidget { } } -/** +/* * Widget for displaying a list of stock items within a stock location. * * Users server-side pagination for snappy results diff --git a/lib/widget/part_detail.dart b/lib/widget/part_detail.dart index 56cbc709..5a03fc03 100644 --- a/lib/widget/part_detail.dart +++ b/lib/widget/part_detail.dart @@ -35,8 +35,6 @@ class PartDetailWidget extends StatefulWidget { class _PartDisplayState extends RefreshableState { - final _editImageKey = GlobalKey(); - @override String getAppBarTitle(BuildContext context) => L10().partDetails; @@ -102,34 +100,6 @@ class _PartDisplayState extends RefreshableState { } } - /** - * 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) { launchApiForm(