mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-15 11:45:31 +00:00
Start of unit tests for the actual API code
This commit is contained in:
@ -201,6 +201,8 @@ class InvenTreeAPI {
|
||||
// Authentication token (initially empty, must be requested)
|
||||
String _token = "";
|
||||
|
||||
bool get hasToken => _token.isNotEmpty;
|
||||
|
||||
/*
|
||||
* Check server connection and display messages if not connected.
|
||||
* Useful as a precursor check before performing operations.
|
||||
@ -278,7 +280,7 @@ class InvenTreeAPI {
|
||||
bool _connecting = false;
|
||||
|
||||
bool isConnected() {
|
||||
return profile != null && _connected && baseUrl.isNotEmpty && _token.isNotEmpty;
|
||||
return profile != null && _connected && baseUrl.isNotEmpty && hasToken;
|
||||
}
|
||||
|
||||
bool isConnecting() {
|
||||
|
14
lib/l10.dart
14
lib/l10.dart
@ -7,16 +7,18 @@ import "package:flutter/material.dart";
|
||||
// Shortcut function to reduce boilerplate!
|
||||
I18N L10()
|
||||
{
|
||||
BuildContext? _ctx = OneContext().context;
|
||||
if (OneContext.hasContext) {
|
||||
BuildContext? _ctx = OneContext().context;
|
||||
|
||||
if (_ctx != null) {
|
||||
I18N? i18n = I18N.of(_ctx);
|
||||
if (_ctx != null) {
|
||||
I18N? i18n = I18N.of(_ctx);
|
||||
|
||||
if (i18n != null) {
|
||||
return i18n;
|
||||
if (i18n != null) {
|
||||
return i18n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for "null" context
|
||||
return I18NEn();
|
||||
return I18NEn();
|
||||
}
|
@ -1,21 +1,19 @@
|
||||
|
||||
/*
|
||||
* Display a snackbar with:
|
||||
*
|
||||
* a) Text on the left
|
||||
* b) Icon on the right
|
||||
*
|
||||
* | Text <icon> |
|
||||
*/
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Display a configurable 'snackbar' at the bottom of the screen
|
||||
*/
|
||||
void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
||||
|
||||
// Escape quickly if we do not have context
|
||||
if (!OneContext.hasContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
BuildContext? context = OneContext().context;
|
||||
|
||||
if (context != null) {
|
||||
|
Reference in New Issue
Block a user