-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nest dom manager and implement the basic example
- Loading branch information
Showing
17 changed files
with
364 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use napi_ohos::Result; | ||
|
||
use crate::{ArkUINodeAttributeItem, ArkUINodeAttributeNumber, ARK_UI_NATIVE_NODE_API_1}; | ||
|
||
use super::ArkUIAttributeBasic; | ||
|
||
pub trait ArkUICommonFontAttribute: ArkUIAttributeBasic { | ||
fn set_font_size(&self, font_size: f32) -> Result<()> { | ||
let font_size_property = | ||
ArkUINodeAttributeItem::NumberValue(vec![ArkUINodeAttributeNumber::Float(font_size)]); | ||
ARK_UI_NATIVE_NODE_API_1.set_attribute( | ||
self.raw(), | ||
crate::ArkUINodeAttributeType::FontSize, | ||
font_size_property, | ||
)?; | ||
Ok(()) | ||
} | ||
|
||
fn set_font_color(&self, font_color: u32) -> Result<()> { | ||
let font_color_property = | ||
ArkUINodeAttributeItem::NumberValue(vec![ArkUINodeAttributeNumber::Uint(font_color)]); | ||
ARK_UI_NATIVE_NODE_API_1.set_attribute( | ||
self.raw(), | ||
crate::ArkUINodeAttributeType::FontColor, | ||
font_color_property, | ||
)?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod common; | ||
mod font; | ||
|
||
pub use common::*; | ||
pub use font::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use napi_ohos::Result; | ||
|
||
use crate::{ | ||
ArkUIAttributeBasic, ArkUICommonAttribute, ArkUINode, ArkUINodeAttributeItem, | ||
ArkUINodeAttributeNumber, ArkUINodeType, ScrollBarDisplayMode, ARK_UI_NATIVE_NODE_API_1, | ||
}; | ||
|
||
pub struct List(ArkUINode); | ||
|
||
impl List { | ||
pub fn new() -> Result<Self> { | ||
let list = ARK_UI_NATIVE_NODE_API_1.create_node(ArkUINodeType::List)?; | ||
Ok(Self(ArkUINode { | ||
raw: list, | ||
children: Vec::new(), | ||
tag: ArkUINodeType::List, | ||
})) | ||
} | ||
|
||
pub fn set_scroll_bar_state(&mut self, mode: ScrollBarDisplayMode) -> Result<()> { | ||
let scroll_bar_display_mode_property = | ||
ArkUINodeAttributeItem::NumberValue(vec![ArkUINodeAttributeNumber::Int(mode.into())]); | ||
ARK_UI_NATIVE_NODE_API_1.set_attribute( | ||
&self.0, | ||
crate::ArkUINodeAttributeType::ScrollBarDisplayMode, | ||
scroll_bar_display_mode_property, | ||
)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl From<List> for ArkUINode { | ||
fn from(list: List) -> Self { | ||
list.0 | ||
} | ||
} | ||
|
||
impl ArkUIAttributeBasic for List { | ||
fn raw(&self) -> &ArkUINode { | ||
&self.0 | ||
} | ||
|
||
fn borrow_mut(&mut self) -> &mut ArkUINode { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl ArkUICommonAttribute for List {} |
36 changes: 36 additions & 0 deletions
36
crates/arkui/src/component/built_in_component/list_item.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use napi_ohos::Result; | ||
|
||
use crate::{ | ||
ArkUIAttributeBasic, ArkUICommonAttribute, ArkUINode, ArkUINodeType, ARK_UI_NATIVE_NODE_API_1, | ||
}; | ||
|
||
pub struct ListItem(ArkUINode); | ||
|
||
impl ListItem { | ||
pub fn new() -> Result<Self> { | ||
let list_item = ARK_UI_NATIVE_NODE_API_1.create_node(ArkUINodeType::ListItem)?; | ||
Ok(Self(ArkUINode { | ||
raw: list_item, | ||
children: Vec::new(), | ||
tag: ArkUINodeType::ListItem, | ||
})) | ||
} | ||
} | ||
|
||
impl From<ListItem> for ArkUINode { | ||
fn from(list_item: ListItem) -> Self { | ||
list_item.0 | ||
} | ||
} | ||
|
||
impl ArkUIAttributeBasic for ListItem { | ||
fn raw(&self) -> &ArkUINode { | ||
&self.0 | ||
} | ||
|
||
fn borrow_mut(&mut self) -> &mut ArkUINode { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl ArkUICommonAttribute for ListItem {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
mod list; | ||
mod list_item; | ||
mod text; | ||
|
||
pub use list::*; | ||
pub use list_item::*; | ||
pub use text::*; |
Oops, something went wrong.