Skip to content

Commit

Permalink
添加flutter ohos项目
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangruiyu committed Dec 12, 2024
1 parent 930612d commit ce159cf
Show file tree
Hide file tree
Showing 71 changed files with 1,634 additions and 73 deletions.
27 changes: 25 additions & 2 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@
# This file should be version controlled and should not be manually edited.

version:
revision: bbfbf1770cca2da7c82e887e4e4af910034800b6
channel: stable
revision: "c44cfb3a15b27abcfd6056ff447d6256cde7bc19"
channel: "oh-3.22.0"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: android
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ios
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
42 changes: 40 additions & 2 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,45 @@
# This file should be version controlled and should not be manually edited.

version:
revision: bbfbf1770cca2da7c82e887e4e4af910034800b6
channel: stable
revision: "c44cfb3a15b27abcfd6056ff447d6256cde7bc19"
channel: "oh-3.22.0"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: android
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ios
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: linux
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: macos
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: web
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: windows
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ohos
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
19 changes: 19 additions & 0 deletions example/ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
*.har
**/BuildProfile.ets
**/oh-package-lock.json5

**/src/main/resources/rawfile/flutter_assets/
**/libs/arm64-v8a/libapp.so
**/libs/arm64-v8a/libflutter.so
**/libs/arm64-v8a/libvmservice_snapshot.so
10 changes: 10 additions & 0 deletions example/ohos/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "com.gstory.example",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions example/ohos/AppScope/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "example"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions example/ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

{
"app": {
"signingConfigs": [],
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
7 changes: 7 additions & 0 deletions example/ohos/entry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
29 changes: 29 additions & 0 deletions example/ohos/entry/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
17 changes: 17 additions & 0 deletions example/ohos/entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
9 changes: 9 additions & 0 deletions example/ohos/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {}
}
24 changes: 24 additions & 0 deletions example/ohos/entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos';
import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';

export default class EntryAbility extends FlutterAbility {
configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
}
38 changes: 38 additions & 0 deletions example/ohos/entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import common from '@ohos.app.ability.common';
import { FlutterPage } from '@ohos/flutter_ohos'

let storage = LocalStorage.getShared()
const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'

@Entry(storage)
@Component
struct Index {
private context = getContext(this) as common.UIAbilityContext
@LocalStorageLink('viewId') viewId: string = "";

build() {
Column() {
FlutterPage({ viewId: this.viewId })
}
}

onBackPress(): boolean {
this.context.eventHub.emit(EVENT_BACK_PRESS)
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FlutterEngine, Log } from '@ohos/flutter_ohos';

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Ohos platform.
*/

const TAG = "GeneratedPluginRegistrant";

export class GeneratedPluginRegistrant {

static registerWith(flutterEngine: FlutterEngine) {
try {
} catch (e) {
Log.e(
TAG,
"Tried to register plugins with FlutterEngine ("
+ flutterEngine
+ ") failed.");
Log.e(TAG, "Received exception while registering", e);
}
}
}
53 changes: 53 additions & 0 deletions example/ohos/entry/src/main/module.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"requestPermissions": [
{"name" : "ohos.permission.INTERNET"},
]
}
}
8 changes: 8 additions & 0 deletions example/ohos/entry/src/main/resources/base/element/color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
Loading

0 comments on commit ce159cf

Please sign in to comment.