Skip to content

Commit 20ed049

Browse files
committed
update flutter things
1 parent b5ca4b8 commit 20ed049

11 files changed

+27
-102
lines changed

ui_flutter/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Flutter implementation of UI for jCRM
66

77
## Run UI
88
```shell
9-
flutter run -d chrome --dart-define=base_url=https://localhost:8090
9+
flutter run -d chrome --wasm --dart-define=base_url=https://localhost:8090
1010
```
1111

1212
This project is a starting point for a Flutter application.

ui_flutter/analysis_options.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# packages, and plugins designed to encourage good coding practices.
1010
include: package:flutter_lints/flutter.yaml
1111

12+
formatter:
13+
page_width: 120
14+
1215
linter:
1316
# The lint rules applied to this project can be customized in the
1417
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
@@ -27,3 +30,4 @@ linter:
2730

2831
# Additional information about this file can be found at
2932
# https://dart.dev/guides/language/analysis-options
33+

ui_flutter/lib/main.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import 'package:provider/provider.dart';
33

44
import 'src/jcrm/ui/flutter/config/application_config.dart';
55
import 'src/jcrm/ui/flutter/app/application_widget.dart';
6-
import 'src/jcrm/ui/flutter/service/security_service.dart';
76

87
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
98

109
void main() {
1110
setUrlStrategy(PathUrlStrategy());
1211
runApp(ApplicationConfig((context, child) {
13-
return ApplicationWidget(context.watch<SecurityService>());
12+
return ApplicationWidget(context.watch());
1413
}));
1514
}

ui_flutter/lib/src/jcrm/ui/flutter/config/application_config.dart

+8-20
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,19 @@ import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/service/http_service.dart';
77
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/service/registration_service.dart';
88
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/service/security_service.dart';
99

10-
import 'dart:html';
10+
import 'package:web/web.dart';
1111

1212
class ApplicationConfig extends MultiProvider {
1313
ApplicationConfig(TransitionBuilder appBuilder, {Key? appKey})
1414
: super(
1515
key: appKey,
1616
providers: [
17-
Provider(create: (context) => ErrorService())
17+
Provider(create: (context) => ErrorService()),
18+
Provider(create: (context) => HttpService(context.read())),
19+
Provider(create: (context) => RegistrationService(context.read())),
20+
ChangeNotifierProvider(create: (context) => SecurityService(context.read(), window.localStorage)),
21+
RepositoriesConfig(),
22+
UiServicesConfig()
1823
],
19-
child: MultiProvider(
20-
providers: [
21-
Provider(create: (context) => HttpService(context.read<ErrorService>()))
22-
],
23-
child: MultiProvider(
24-
providers: [
25-
Provider(create: (context) => RegistrationService(context.read<HttpService>()))
26-
],
27-
child: MultiProvider(
28-
providers: [
29-
ChangeNotifierProvider(create: (context) => SecurityService(context.read<HttpService>(), window.localStorage)),
30-
],
31-
child: MultiProvider(
32-
providers: [
33-
RepositoriesConfig(),
34-
UiServicesConfig()
35-
],
36-
builder: appBuilder)))));
24+
builder: appBuilder);
3725
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import 'package:provider/provider.dart';
22
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/repository/user_repository.dart';
3-
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/service/http_service.dart';
4-
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/service/security_service.dart';
53

64
class RepositoriesConfig extends MultiProvider {
75
RepositoriesConfig({super.key})
86
: super(providers: [
9-
Provider(create: (context) => UserRepository(
10-
context.read<HttpService>(),
11-
context.read<SecurityService>()))
7+
Provider(create: (context) => UserRepository(context.read(), context.read()))
128
]);
139
}

ui_flutter/lib/src/jcrm/ui/flutter/page/book_details.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class BookDetailsScreen extends StatelessWidget {
3434
children: [
3535
Text(
3636
book!.title,
37-
style: Theme.of(context).textTheme.headline4,
37+
style: Theme.of(context).textTheme.headlineMedium,
3838
),
3939
Text(
4040
book!.author.name,
41-
style: Theme.of(context).textTheme.subtitle1,
41+
style: Theme.of(context).textTheme.titleSmall,
4242
),
4343
TextButton(
4444
child: const Text('View author (Push)'),

ui_flutter/lib/src/jcrm/ui/flutter/page/home_page.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class MyHomePageState extends State<MyHomePage> {
7171
),
7272
Text(
7373
'$_counter',
74-
style: Theme.of(context).textTheme.headline4,
74+
style: Theme.of(context).textTheme.headlineMedium,
7575
),
7676
],
7777
),

ui_flutter/lib/src/jcrm/ui/flutter/page/sign_in.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class _SignInScreenState extends State<SignInScreen> {
4141
mainAxisAlignment: MainAxisAlignment.center,
4242
mainAxisSize: MainAxisSize.min,
4343
children: [
44-
Text('Sign in', style: Theme.of(context).textTheme.headline4),
44+
Text('Sign in', style: Theme.of(context).textTheme.headlineMedium),
4545
TextField(
4646
decoration: const InputDecoration(labelText: 'Username'),
4747
controller: _usernameController,

ui_flutter/lib/src/jcrm/ui/flutter/routing.dart

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright 2021, the Flutter project authors. Please see the AUTHORS file
2-
// for details. All rights reserved. Use of this source code is governed by a
3-
// BSD-style license that can be found in the LICENSE file.
41

52
export 'routing/delegate.dart';
63
export 'routing/parsed_route.dart';

ui_flutter/lib/src/jcrm/ui/flutter/service/security_service.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'dart:html';
1+
import 'package:web/web.dart';
22

33
import 'package:flutter/material.dart';
44
import 'package:jcrm_ui_flutter/src/jcrm/ui/flutter/entity/user.dart';
@@ -42,7 +42,7 @@ class SecurityService extends ChangeNotifier {
4242
if (ex is HttpException && ex.error.errorCode == Errors.tokenExpired) {
4343
return refreshToken(restoredToken);
4444
} else {
45-
_localStorage.remove(localStorageKeyToken);
45+
_localStorage.removeItem(localStorageKeyToken);
4646
internalAuthenticate(User.none, emptyToken);
4747
}
4848
}
@@ -59,7 +59,7 @@ class SecurityService extends ChangeNotifier {
5959
_localStorage[localStorageKeyToken] = response.token;
6060
} catch (ex) {
6161
if (ex is HttpException && ex.error.errorCode == Errors.tokenMaxRefreshed) {
62-
_localStorage.remove(localStorageKeyToken);
62+
_localStorage.removeItem(localStorageKeyToken);
6363
}
6464
internalAuthenticate(User.none, emptyToken);
6565
}

ui_flutter/pubspec.yaml

+5-64
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,12 @@ description: Flutter implementation of UI for jCRM
55
# pub.dev using `flutter pub publish`. This is preferred for private packages.
66
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
77

8-
# The following defines the version and build number for your application.
9-
# A version number is three numbers separated by dots, like 1.2.43
10-
# followed by an optional build number separated by a +.
11-
# Both the version and the builder number may be overridden in flutter
12-
# build by specifying --build-name and --build-number, respectively.
13-
# In Android, build-name is used as versionName while build-number used as versionCode.
14-
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15-
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
16-
# Read more about iOS versioning at
17-
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
188
version: 1.0.0+1
199

2010
environment:
21-
sdk: ">=2.19.0 <3.0.0"
11+
sdk: ^3.5.0
12+
flutter: ^3.24.5
2213

23-
# Dependencies specify other packages that your package needs in order to work.
24-
# To automatically upgrade your package dependencies to the latest versions
25-
# consider running `flutter pub upgrade --major-versions`. Alternatively,
26-
# dependencies can be manually updated by changing the version numbers below to
27-
# the latest version available on pub.dev. To see which dependencies have newer
28-
# versions available, run `flutter pub outdated`.
2914
dependencies:
3015
flutter:
3116
sdk: flutter
@@ -36,64 +21,20 @@ dependencies:
3621
quiver: ^3.2.1
3722
url_launcher: ^6.2.1
3823
intl: ^0.20.1
24+
web: ^1.1.0
3925

4026
adaptive_navigation: ^0.0.10
4127
url_strategy: ^0.3.0
4228

43-
# The following adds the Cupertino Icons font to your application.
44-
# Use with the CupertinoIcons class for iOS style icons.
4529
cupertino_icons: ^1.0.8
4630
data_table_2: ^2.5.16
4731

4832
dev_dependencies:
4933
flutter_test:
5034
sdk: flutter
51-
52-
# The "flutter_lints" package below contains a set of recommended lints to
53-
# encourage good coding practices. The lint set provided by the package is
54-
# activated in the `analysis_options.yaml` file located at the root of your
55-
# package. See that file for information about deactivating specific lint
56-
# rules and activating additional ones.
35+
integration_test:
36+
sdk: flutter
5737
flutter_lints: ^5.0.0
5838

59-
# For information on the generic Dart part of this file, see the
60-
# following page: https://dart.dev/tools/pub/pubspec
61-
62-
# The following section is specific to Flutter.
6339
flutter:
64-
65-
# The following line ensures that the Material Icons font is
66-
# included with your application, so that you can use the icons in
67-
# the material Icons class.
6840
uses-material-design: true
69-
70-
# To add assets to your application, add an assets section, like this:
71-
# assets:
72-
# - images/a_dot_burr.jpeg
73-
# - images/a_dot_ham.jpeg
74-
75-
# An image asset can refer to one or more resolution-specific "variants", see
76-
# https://flutter.dev/assets-and-images/#resolution-aware.
77-
78-
# For details regarding adding assets from package dependencies, see
79-
# https://flutter.dev/assets-and-images/#from-packages
80-
81-
# To add custom fonts to your application, add a fonts section here,
82-
# in this "flutter" section. Each entry in this list should have a
83-
# "family" key with the font family name, and a "fonts" key with a
84-
# list giving the asset and other descriptors for the font. For
85-
# example:
86-
# fonts:
87-
# - family: Schyler
88-
# fonts:
89-
# - asset: fonts/Schyler-Regular.ttf
90-
# - asset: fonts/Schyler-Italic.ttf
91-
# style: italic
92-
# - family: Trajan Pro
93-
# fonts:
94-
# - asset: fonts/TrajanPro.ttf
95-
# - asset: fonts/TrajanPro_Bold.ttf
96-
# weight: 700
97-
#
98-
# For details regarding fonts from package dependencies,
99-
# see https://flutter.dev/custom-fonts/#from-packages

0 commit comments

Comments
 (0)