Skip to content

Commit 874da3e

Browse files
committed
Release cnativeapi and nativeapi v0.1.1
- Bump version to 0.1.1 for both cnativeapi and nativeapi - Update cnativeapi dependency constraint to ^0.1.1 in nativeapi - Add CHANGELOG entries for 0.1.1 - Update README files: add platform support table, features list, Work in Progress notice, and correct usage examples
1 parent ff12aa2 commit 874da3e

7 files changed

Lines changed: 172 additions & 15 deletions

File tree

README-ZH.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,33 @@
44

55
🚧 **开发中**: 此包目前正在积极开发中。
66

7+
## 平台支持
8+
9+
| Android | iOS | Linux | macOS | Windows |
10+
|:-------:|:---:|:-----:|:-----:|:-------:|
11+
||||||
12+
13+
## 功能特性
14+
15+
- **窗口管理** — 创建、显示、隐藏、居中窗口;控制标题栏样式、视觉效果和控制按钮
16+
- **托盘图标** — 系统托盘图标,支持菜单和右键菜单触发
17+
- **多屏幕管理** — 枚举和查询多屏幕显示信息
18+
- **菜单** — 原生菜单系统,支持事件回调
19+
- **对话框** — 消息对话框及原生对话框 API
20+
- **辅助功能** — 无障碍管理器 API
21+
- **偏好设置** — 持久化键值存储
22+
- **安全存储** — 加密键值存储
23+
- **URL 打开器** — 使用系统默认浏览器/处理程序打开 URL
24+
- **定位策略** — 灵活的窗口定位策略和位置支持
25+
- **Widget**`ContextMenuRegion` 右键菜单集成组件
26+
727
## 快速开始
828

929
`pubspec.yaml` 中添加 `nativeapi`:
1030

1131
```yaml
1232
dependencies:
13-
nativeapi: ^0.1.0
33+
nativeapi: ^0.1.1
1434
```
1535
1636
然后运行:
@@ -19,16 +39,45 @@ dependencies:
1939
flutter pub get
2040
```
2141

22-
### 使用方法
23-
24-
> 📖 详细的文档和示例即将推出!
42+
## 使用方法
2543

2644
```dart
2745
import 'package:nativeapi/nativeapi.dart';
2846
29-
// 示例用法将在此处添加
47+
// 窗口管理 - 获取当前窗口并进行操作
48+
final windowManager = WindowManager.instance;
49+
final window = windowManager.getCurrent();
50+
window?.show();
51+
window?.center();
52+
window?.titleBarStyle = TitleBarStyle.hidden;
53+
54+
// 监听窗口事件
55+
windowManager.addCallbackListener<WindowFocusedEvent>((event) {
56+
print('窗口获得焦点: ${event.windowId}');
57+
});
58+
59+
// 托盘图标
60+
final trayIcon = TrayIcon();
61+
trayIcon.icon = Image.fromAsset('assets/tray_icon.png');
62+
trayIcon.contextMenu = Menu();
63+
trayIcon.contextMenuTrigger = ContextMenuTrigger.rightClicked;
64+
trayIcon.on<TrayIconClickedEvent>((event) {
65+
print('托盘图标被点击');
66+
});
67+
68+
// URL 打开器(同步调用)
69+
final result = UrlOpener.instance.open('https://example.com');
70+
print('打开结果: ${result.success}');
71+
72+
// 偏好设置(同步调用,使用完记得 dispose)
73+
final prefs = Preferences();
74+
prefs.set('theme', 'dark');
75+
final theme = prefs.get('theme', 'light'); // 第二个参数为默认值
76+
prefs.dispose();
3077
```
3178

79+
> 📖 更详细的文档和示例即将推出。请查看 [`examples/`](https://github.com/libnativeapi/nativeapi-flutter/tree/main/examples) 目录中的示例应用。
80+
3281
## 开发
3382

3483
### 前置要求

README.md

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,33 @@ Flutter bindings for [nativeapi](https://github.com/libnativeapi/libnativeapi) -
44

55
🚧 **Work in Progress**: This package is currently under active development.
66

7+
## Platform Support
8+
9+
| Android | iOS | Linux | macOS | Windows |
10+
|:-------:|:---:|:-----:|:-----:|:-------:|
11+
||||||
12+
13+
## Features
14+
15+
- **Window Management** — create, show, hide, center windows; control title bar style, visual effects, and control buttons
16+
- **Tray Icon** — system tray icon with menu and context menu trigger support
17+
- **Display Management** — enumerate and query multi-screen display info
18+
- **Menu** — native menu system with event callbacks
19+
- **Dialogs** — message dialogs and native dialog APIs
20+
- **Accessibility** — accessibility manager API
21+
- **Preferences** — persistent key-value storage
22+
- **Secure Storage** — encrypted key-value storage
23+
- **URL Opener** — open URLs with the system default browser/handler
24+
- **Positioning** — flexible window positioning strategies and placement support
25+
- **Widgets**`ContextMenuRegion` for context menu integration
26+
727
## Getting Started
828

929
Add `nativeapi` to your `pubspec.yaml`:
1030

1131
```yaml
1232
dependencies:
13-
nativeapi: ^0.1.0
33+
nativeapi: ^0.1.1
1434
```
1535
1636
Then run:
@@ -19,16 +39,45 @@ Then run:
1939
flutter pub get
2040
```
2141

22-
### Usage
23-
24-
> 📖 Detailed documentation and examples are coming soon!
42+
## Usage
2543

2644
```dart
2745
import 'package:nativeapi/nativeapi.dart';
2846
29-
// Example usage will be added here
47+
// Window management - get the current window and manipulate it
48+
final windowManager = WindowManager.instance;
49+
final window = windowManager.getCurrent();
50+
window?.show();
51+
window?.center();
52+
window?.titleBarStyle = TitleBarStyle.hidden;
53+
54+
// Listen to window events
55+
windowManager.addCallbackListener<WindowFocusedEvent>((event) {
56+
print('Window focused: ${event.windowId}');
57+
});
58+
59+
// Tray icon
60+
final trayIcon = TrayIcon();
61+
trayIcon.icon = Image.fromAsset('assets/tray_icon.png');
62+
trayIcon.contextMenu = Menu();
63+
trayIcon.contextMenuTrigger = ContextMenuTrigger.rightClicked;
64+
trayIcon.on<TrayIconClickedEvent>((event) {
65+
print('Tray icon clicked');
66+
});
67+
68+
// URL opener (synchronous)
69+
final result = UrlOpener.instance.open('https://example.com');
70+
print('Opened: ${result.success}');
71+
72+
// Preferences (synchronous, dispose when done)
73+
final prefs = Preferences();
74+
prefs.set('theme', 'dark');
75+
final theme = prefs.get('theme', 'light'); // second arg is default value
76+
prefs.dispose();
3077
```
3178

79+
> 📖 More detailed documentation and examples are coming soon. See the [`examples/`](https://github.com/libnativeapi/nativeapi-flutter/tree/main/examples) directory for working sample apps.
80+
3281
## Development
3382

3483
### Prerequisites
@@ -57,7 +106,7 @@ git submodule update --init --recursive
57106
melos bootstrap
58107
```
59108

60-
4. Run the example app:
109+
4. Run an example app:
61110

62111
```bash
63112
cd examples/display_example

packages/cnativeapi/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.1.1
2+
3+
* Add multi-platform FFI C bindings (Android, iOS, Linux, macOS, Windows)
4+
* Migrate iOS and macOS native bindings to SwiftPM
5+
* Add UrlOpener C bindings
6+
* Add autostart and global shortcuts C bindings
7+
* Add window visual effects and color C bindings
8+
* Add title bar style and control button C bindings
9+
* Introduce bindgen code generation toolchain
10+
111
## 0.1.0
212

313
* Initial release

packages/cnativeapi/README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
# cnativeapi
22

3-
Native API C bindings for Flutter
3+
Native API C bindings for Flutter, auto-generated via [ffigen](https://pub.dev/packages/ffigen) from the [libnativeapi](https://github.com/libnativeapi/nativeapi) C library.
4+
5+
> This package provides low-level FFI bindings and is typically used as an internal dependency of [`nativeapi`](https://pub.dev/packages/nativeapi). You generally don't need to depend on it directly.
6+
7+
## Platform Support
8+
9+
| Android | iOS | Linux | macOS | Windows |
10+
|:-------:|:---:|:-----:|:-----:|:-------:|
11+
||||||
12+
13+
## Usage
14+
15+
If you need to use the raw C bindings directly:
16+
17+
```dart
18+
import 'package:cnativeapi/cnativeapi.dart';
19+
```
20+
21+
For higher-level Dart APIs, use the [`nativeapi`](https://pub.dev/packages/nativeapi) package instead.
22+
23+
## Regenerating Bindings
24+
25+
Bindings are generated from C headers using `ffigen`. To regenerate:
26+
27+
```bash
28+
cd packages/cnativeapi
29+
dart run ffigen --config ffigen.yaml
30+
```
31+
32+
Regeneration is needed when:
33+
- The native C library ([libnativeapi/nativeapi](https://github.com/libnativeapi/nativeapi)) is updated
34+
- The `ffigen.yaml` configuration is modified
35+
36+
## License
37+
38+
[MIT](./LICENSE)

packages/cnativeapi/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: cnativeapi
22
description: "Native API C bindings for Flutter"
3-
version: 0.1.0
3+
version: 0.1.1
44
homepage: https://github.com/libnativeapi/nativeapi-flutter
55
resolution: workspace
66

packages/nativeapi/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 0.1.1
2+
3+
* Add `WindowManager` API with full lifecycle support (show, hide, center, pre-show/pre-hide hooks, visual effects, title bar style, control buttons)
4+
* Add `TrayManager` / `TrayIcon` API with context menu trigger support
5+
* Add `DisplayManager` / `Display` multi-screen management API
6+
* Add `Menu` / `MenuEvent` menu system
7+
* Add `MessageDialog` / `Dialog` APIs
8+
* Add `AccessibilityManager` API
9+
* Add `Preferences` storage
10+
* Add `SecureStorage` secure storage
11+
* Add `UrlOpener` API
12+
* Add `PositioningStrategy` / `Placement` window positioning support
13+
* Add `ContextMenuRegion` widget
14+
115
## 0.1.0
216

317
* Initial release

packages/nativeapi/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nativeapi
22
description: "Flutter bindings for nativeapi - providing seamless, unified access to native system APIs."
3-
version: 0.1.0
3+
version: 0.1.1
44
homepage: https://github.com/libnativeapi/nativeapi-flutter
55
resolution: workspace
66

@@ -12,7 +12,7 @@ dependencies:
1212
ffi: ">=1.2.1 <3.0.0"
1313
flutter:
1414
sdk: flutter
15-
cnativeapi: ^0.1.0
15+
cnativeapi: ^0.1.1
1616
path: ^1.9.1
1717
meta: ^1.16.0
1818

0 commit comments

Comments
 (0)