Handle web imports
This commit is contained in:
parent
25f146dcb6
commit
9665c4212b
|
|
@ -1,16 +1,17 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
//import 'dart:html' as html;
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/static/static_state.dart';
|
import 'package:invoiceninja_flutter/redux/static/static_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/company/company_state.dart';
|
import 'package:invoiceninja_flutter/redux/company/company_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
import 'package:invoiceninja_flutter/data/file_storage.dart';
|
import 'package:invoiceninja_flutter/data/file_storage.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/web_stub.dart'
|
||||||
|
if (dart.library.html) 'package:invoiceninja_flutter/utils/web.dart';
|
||||||
|
|
||||||
class PersistenceRepository {
|
class PersistenceRepository {
|
||||||
const PersistenceRepository({
|
const PersistenceRepository({
|
||||||
|
|
@ -25,11 +26,8 @@ class PersistenceRepository {
|
||||||
state.rebuild((b) => b..userCompany.token.token = '');
|
state.rebuild((b) => b..userCompany.token.token = '');
|
||||||
|
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
/*
|
print('## COOKIE: ${readCookie()}');
|
||||||
print('## COOKIE: ${html.window.document.cookie}');
|
writeCookie('token', token);
|
||||||
html.window.document.cookie =
|
|
||||||
'token=$token; expires=Sat, 19 Dec 2099 12:00:00 UTC; Secure; SameSite=Strict;';
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO persist stateWithoutToken
|
// TODO persist stateWithoutToken
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/web.dart';
|
import 'package:invoiceninja_flutter/utils/web_stub.dart'
|
||||||
|
if (dart.library.html) 'package:invoiceninja_flutter/utils/web.dart';
|
||||||
|
|
||||||
class CompanyDetails extends StatefulWidget {
|
class CompanyDetails extends StatefulWidget {
|
||||||
const CompanyDetails({
|
const CompanyDetails({
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:html';
|
import 'dart:html';
|
||||||
|
|
||||||
|
void writeCookie(String key, String value) {
|
||||||
|
window.document.cookie =
|
||||||
|
'$key=$value; expires=Sat, 19 Dec 2099 12:00:00 UTC; Secure; SameSite=Strict;';
|
||||||
|
}
|
||||||
|
|
||||||
|
String readCookie() {
|
||||||
|
return window.document.cookie;
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> getFileOnWeb() {
|
Future<String> getFileOnWeb() {
|
||||||
final completer = new Completer<String>();
|
final completer = new Completer<String>();
|
||||||
final InputElement input = document.createElement('input');
|
final InputElement input = document.createElement('input');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
void writeCookie(String key, String value) {}
|
||||||
|
|
||||||
|
String readCookie() => null;
|
||||||
|
|
||||||
|
Future<String> getFileOnWeb() => null;
|
||||||
|
|
@ -562,7 +562,7 @@ packages:
|
||||||
name: native_pdf_renderer
|
name: native_pdf_renderer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.2"
|
version: "1.7.0"
|
||||||
native_pdf_view:
|
native_pdf_view:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -597,7 +597,7 @@ packages:
|
||||||
name: package_config
|
name: package_config
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.9.0"
|
||||||
package_resolver:
|
package_resolver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -826,7 +826,7 @@ packages:
|
||||||
name: stream_transform
|
name: stream_transform
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -1003,5 +1003,5 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.7.0-dev <3.0.0"
|
dart: ">=2.7.0 <3.0.0"
|
||||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue