Skip to content

Commit 0334bba

Browse files
committed
update ui device information
1 parent 2ad05a2 commit 0334bba

File tree

6 files changed

+123
-114
lines changed

6 files changed

+123
-114
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Any questions join the [Mixin Flutter group][mixin_group_url]
2020
| [fts5_simple](./packages/fts5_simple) | [![pub package][fts5_simple_version]][fts5_simple_pub] | [![likes][fts5_simple_likes]][fts5_simple_score] | Windows, Linux, macOS |
2121
| [desktop_multi_window](./packages/desktop_multi_window) | [![pub package][desktop_multi_window_version]][desktop_multi_window_pub] | [![likes][desktop_multi_window_likes]][desktop_multi_window_score] | Windows, Linux, macOS |
2222
| [mixin_logger](./packages/mixin_logger) | [![pub package][mixin_logger_version]][mixin_logger_pub] | [![likes][mixin_logger_likes]][mixin_logger_score] | All Platforms |
23-
| [ui_device](./packages/ui_device) | NONE | NONE | macOS, iOS |
24-
| [string_tokenizer](./packages/string_tokenizer) | NONE | NONE | macOS, iOS |
23+
| [ui_device](./packages/ui_device) | [![pub package][ui_device_version]][ui_device_pub] | [![likes][ui_device_likes]][ui_device_score] | iOS |
24+
| [string_tokenizer](./packages/string_tokenizer) | Not Published | Not Published | macOS, iOS |
2525

2626
[desktop_drop_version]: https://img.shields.io/pub/v/desktop_drop.svg
2727

@@ -94,3 +94,11 @@ Any questions join the [Mixin Flutter group][mixin_group_url]
9494
[mixin_logger_likes]: https://img.shields.io/pub/likes/mixin_logger
9595

9696
[mixin_logger_score]: https://pub.dev/packages/mixin_logger/score
97+
98+
[ui_device_version]: https://img.shields.io/pub/v/ui_device.svg
99+
100+
[ui_device_pub]: https://pub.dev/packages/ui_device
101+
102+
[ui_device_likes]: https://img.shields.io/pub/likes/ui_device
103+
104+
[ui_device_score]: https://pub.dev/packages/ui_device/score

packages/ui_device/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## 0.0.1
22

3-
* TODO: Describe initial release.
3+
* initial release.

packages/ui_device/LICENSE

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
TODO: Add your license here.
1+
MIT License
2+
3+
Copyright (c) 2023 Mixin Network
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/ui_device/README.md

Lines changed: 26 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,41 @@
11
# ui_device
22

3-
A new Flutter FFI plugin project.
3+
A Flutter plugin for accessing UIDevice information on iOS.
44

5-
## Getting Started
5+
## Usage
66

7-
This project is a starting point for a Flutter
8-
[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop),
9-
a specialized package that includes native code directly invoked with Dart FFI.
10-
11-
## Project stucture
12-
13-
This template uses the following structure:
14-
15-
* `src`: Contains the native source code, and a CmakeFile.txt file for building
16-
that source code into a dynamic library.
17-
18-
* `lib`: Contains the Dart code that defines the API of the plugin, and which
19-
calls into the native code using `dart:ffi`.
20-
21-
* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files
22-
for building and bundling the native code library with the platform application.
23-
24-
## Buidling and bundling native code
25-
26-
The `pubspec.yaml` specifies FFI plugins as follows:
27-
28-
```yaml
29-
plugin:
30-
platforms:
31-
some_platform:
32-
ffiPlugin: true
33-
```
34-
35-
This configuration invokes the native build for the various target platforms
36-
and bundles the binaries in Flutter applications using these FFI plugins.
37-
38-
This can be combined with dartPluginClass, such as when FFI is used for the
39-
implementation of one platform in a federated plugin:
7+
To use this plugin, add `ui_device` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/packages-and-plugins/using-packages).
408

419
```yaml
42-
plugin:
43-
implements: some_other_plugin
44-
platforms:
45-
some_platform:
46-
dartPluginClass: SomeClass
47-
ffiPlugin: true
10+
dependencies:
11+
ui_device:
12+
git:
13+
url: https://github.com/MixinNetwork/flutter-plugins.git
14+
path: packages/ui_device
4815
```
4916
50-
A plugin can have both FFI and method channels:
17+
Then import the package:
5118
52-
```yaml
53-
plugin:
54-
platforms:
55-
some_platform:
56-
pluginClass: SomeName
57-
ffiPlugin: true
19+
```dart
20+
import 'package:ui_device/ui_device.dart' as ui_device;
5821
```
5922

60-
The native build systems that are invoked by FFI (and method channel) plugins are:
61-
62-
* For Android: Gradle, which invokes the Android NDK for native builds.
63-
* See the documentation in android/build.gradle.
64-
* For iOS and MacOS: Xcode, via CocoaPods.
65-
* See the documentation in ios/ui_device.podspec.
66-
* See the documentation in macos/ui_device.podspec.
67-
* For Linux and Windows: CMake.
68-
* See the documentation in linux/CMakeLists.txt.
69-
* See the documentation in windows/CMakeLists.txt.
70-
71-
## Binding to native code
23+
### Getting Device Information
7224

73-
To use the native code, bindings in Dart are needed.
74-
To avoid writing these by hand, they are generated from the header file
75-
(`src/ui_device.h`) by `package:ffigen`.
76-
Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`.
25+
`ui_device` provides a single method `current` which returns a `DeviceInfo` object containing various properties of the device.
7726

78-
## Invoking native code
79-
80-
Very short-running native functions can be directly invoked from any isolate.
81-
For example, see `sum` in `lib/ui_device.dart`.
82-
83-
Longer-running functions should be invoked on a helper isolate to avoid
84-
dropping frames in Flutter applications.
85-
For example, see `sumAsync` in `lib/ui_device.dart`.
86-
87-
## Flutter help
27+
```dart
28+
final current = ui_device.current;
29+
print(current.systemName); // e.g. "iOS"
30+
print(current.systemVersion); // e.g. "14.4.1"
31+
print(current.name); // e.g. "iPhone XS Max"
32+
print(current.model); // e.g. "iPhone11,6"
33+
```
8834

89-
For help getting started with Flutter, view our
90-
[online documentation](https://flutter.dev/docs), which offers tutorials,
91-
samples, guidance on mobile development, and a full API reference.
35+
You can also get additional information such as the `localizedModel`, `identifierForVendor`, and `isPhysicalDevice`.
9236

37+
```dart
38+
final current = ui_device.current;
39+
print(current.localizedModel); // e.g. "iPhone"
40+
print(current.identifierForVendor); // a unique identifier for a device, persisted across app installs
41+
```

packages/ui_device/example/pubspec.lock

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,64 @@ packages:
55
dependency: transitive
66
description:
77
name: async
8-
url: "https://pub.dartlang.org"
8+
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
9+
url: "https://pub.dev"
910
source: hosted
10-
version: "2.9.0"
11+
version: "2.10.0"
1112
boolean_selector:
1213
dependency: transitive
1314
description:
1415
name: boolean_selector
15-
url: "https://pub.dartlang.org"
16+
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17+
url: "https://pub.dev"
1618
source: hosted
17-
version: "2.1.0"
19+
version: "2.1.1"
1820
characters:
1921
dependency: transitive
2022
description:
2123
name: characters
22-
url: "https://pub.dartlang.org"
24+
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
25+
url: "https://pub.dev"
2326
source: hosted
2427
version: "1.2.1"
2528
clock:
2629
dependency: transitive
2730
description:
2831
name: clock
29-
url: "https://pub.dartlang.org"
32+
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33+
url: "https://pub.dev"
3034
source: hosted
3135
version: "1.1.1"
3236
collection:
3337
dependency: transitive
3438
description:
3539
name: collection
36-
url: "https://pub.dartlang.org"
40+
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
41+
url: "https://pub.dev"
3742
source: hosted
38-
version: "1.16.0"
43+
version: "1.17.0"
3944
cupertino_icons:
4045
dependency: "direct main"
4146
description:
4247
name: cupertino_icons
43-
url: "https://pub.dartlang.org"
48+
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
49+
url: "https://pub.dev"
4450
source: hosted
4551
version: "1.0.5"
4652
fake_async:
4753
dependency: transitive
4854
description:
4955
name: fake_async
50-
url: "https://pub.dartlang.org"
56+
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
57+
url: "https://pub.dev"
5158
source: hosted
5259
version: "1.3.1"
5360
ffi:
5461
dependency: transitive
5562
description:
5663
name: ffi
57-
url: "https://pub.dartlang.org"
64+
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
65+
url: "https://pub.dev"
5866
source: hosted
5967
version: "2.0.1"
6068
flutter:
@@ -66,47 +74,61 @@ packages:
6674
dependency: "direct dev"
6775
description:
6876
name: flutter_lints
69-
url: "https://pub.dartlang.org"
77+
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
78+
url: "https://pub.dev"
7079
source: hosted
7180
version: "2.0.1"
7281
flutter_test:
7382
dependency: "direct dev"
7483
description: flutter
7584
source: sdk
7685
version: "0.0.0"
86+
js:
87+
dependency: transitive
88+
description:
89+
name: js
90+
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
91+
url: "https://pub.dev"
92+
source: hosted
93+
version: "0.6.5"
7794
lints:
7895
dependency: transitive
7996
description:
8097
name: lints
81-
url: "https://pub.dartlang.org"
98+
sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3"
99+
url: "https://pub.dev"
82100
source: hosted
83101
version: "2.0.0"
84102
matcher:
85103
dependency: transitive
86104
description:
87105
name: matcher
88-
url: "https://pub.dartlang.org"
106+
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
107+
url: "https://pub.dev"
89108
source: hosted
90-
version: "0.12.12"
109+
version: "0.12.13"
91110
material_color_utilities:
92111
dependency: transitive
93112
description:
94113
name: material_color_utilities
95-
url: "https://pub.dartlang.org"
114+
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
115+
url: "https://pub.dev"
96116
source: hosted
97-
version: "0.1.5"
117+
version: "0.2.0"
98118
meta:
99119
dependency: transitive
100120
description:
101121
name: meta
102-
url: "https://pub.dartlang.org"
122+
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
123+
url: "https://pub.dev"
103124
source: hosted
104125
version: "1.8.0"
105126
path:
106127
dependency: transitive
107128
description:
108129
name: path
109-
url: "https://pub.dartlang.org"
130+
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
131+
url: "https://pub.dev"
110132
source: hosted
111133
version: "1.8.2"
112134
sky_engine:
@@ -118,44 +140,50 @@ packages:
118140
dependency: transitive
119141
description:
120142
name: source_span
121-
url: "https://pub.dartlang.org"
143+
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
144+
url: "https://pub.dev"
122145
source: hosted
123-
version: "1.9.0"
146+
version: "1.9.1"
124147
stack_trace:
125148
dependency: transitive
126149
description:
127150
name: stack_trace
128-
url: "https://pub.dartlang.org"
151+
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
152+
url: "https://pub.dev"
129153
source: hosted
130-
version: "1.10.0"
154+
version: "1.11.0"
131155
stream_channel:
132156
dependency: transitive
133157
description:
134158
name: stream_channel
135-
url: "https://pub.dartlang.org"
159+
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
160+
url: "https://pub.dev"
136161
source: hosted
137-
version: "2.1.0"
162+
version: "2.1.1"
138163
string_scanner:
139164
dependency: transitive
140165
description:
141166
name: string_scanner
142-
url: "https://pub.dartlang.org"
167+
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
168+
url: "https://pub.dev"
143169
source: hosted
144-
version: "1.1.1"
170+
version: "1.2.0"
145171
term_glyph:
146172
dependency: transitive
147173
description:
148174
name: term_glyph
149-
url: "https://pub.dartlang.org"
175+
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
176+
url: "https://pub.dev"
150177
source: hosted
151178
version: "1.2.1"
152179
test_api:
153180
dependency: transitive
154181
description:
155182
name: test_api
156-
url: "https://pub.dartlang.org"
183+
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
184+
url: "https://pub.dev"
157185
source: hosted
158-
version: "0.4.12"
186+
version: "0.4.16"
159187
ui_device:
160188
dependency: "direct main"
161189
description:
@@ -167,9 +195,10 @@ packages:
167195
dependency: transitive
168196
description:
169197
name: vector_math
170-
url: "https://pub.dartlang.org"
198+
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
199+
url: "https://pub.dev"
171200
source: hosted
172-
version: "2.1.2"
201+
version: "2.1.4"
173202
sdks:
174203
dart: ">=2.18.0 <3.0.0"
175204
flutter: ">=3.0.0"

0 commit comments

Comments
 (0)