-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Drawer Component in Hyperview #83
Comments
Here's how to integrate the drawer with the existing main.xml template in Rust/OpenAgents: <?xml version="1.0" encoding="UTF-8" ?>
<doc xmlns="https://hyperview.org/hyperview"
xmlns:local="https://openagents.com/hyperview-local">
<screen style="screen">
<styles>
<!-- Existing styles -->
<!-- Add drawer-specific styles -->
<style id="drawerContent"
backgroundColor="#000"
flex="1"
width="100%"
padding="24" />
<style id="drawerItem"
flexDirection="row"
alignItems="center"
paddingVertical="12"
paddingHorizontal="16" />
<style id="drawerItemText"
color="#fff"
fontSize="16"
marginLeft="12" />
</styles>
<local:drawer>
<!-- Drawer Content -->
<view slot="drawer-content" style="drawerContent">
<!-- New Chat Button -->
<view style="drawerItem" href="/new-chat">
<local:svg src="plus" width="20" height="20" color="#fff" />
<text style="drawerItemText">New Chat</text>
</view>
<!-- Chat List -->
<list>
<item key="1" style="drawerItem" href="/chat/1">
<local:svg src="message" width="20" height="20" color="#fff" />
<text style="drawerItemText">Chat #1</text>
</item>
<!-- More chat items -->
</list>
<!-- Bottom Section -->
<view style="menuContainerBottom">
<view style="drawerItem" href="/profile">
<local:svg src="user" width="20" height="20" color="#fff" />
<text style="drawerItemText">Profile</text>
</view>
<view style="drawerItem" href="/wallet">
<local:svg src="wallet" width="20" height="20" color="#fff" />
<text style="drawerItemText">Wallet</text>
</view>
</view>
</view>
<!-- Main Content -->
<view slot="main-content">
<body style="body">
<view style="device">
<!-- Top Section with menu button -->
<view style="menuContainerTop">
<behavior trigger="press" action="open-drawer" />
<local:svg src="menu" width="20" height="20" />
</view>
<!-- Existing Middle Section -->
<view style="conversationContainer">
<view>
<local:image src="loading" style="logo" />
</view>
</view>
<!-- Existing Bottom Section -->
<view style="inputBox">
<view style="voiceContainer">
<local:svg src="voice" width="26" height="26" color="#515151" />
<text style="askAnything">Ask anything</text>
</view>
<view style="sendContainer">
<local:svg src="send" width="19" height="19" color="#515151" />
</view>
</view>
</view>
</body>
</view>
</local:drawer>
</screen>
</doc> In your Rust backend: use askama::Template;
#[derive(Template)]
#[template(path = "pages/main.xml")]
struct MainTemplate {
chats: Vec<Chat>,
// other template data
}
async fn render_main() -> impl Responder {
let template = MainTemplate {
chats: get_chats().await,
// populate other data
};
HttpResponse::Ok()
.content_type("application/xml")
.body(template.render().unwrap())
} Key changes:
The drawer content follows the same structure as the React Native implementation but in HXML format. (Comment from OpenAgents) |
Behavior AnalysisLooking at the logs and implementation, here's what's happening:
The chain breaks after returning the update action. We're not seeing any logs from:
a) Behavior Return Format return {
action: 'update',
behaviorElement: current,
options: {
behavior: {
action: 'set-drawer-state',
state: element.getAttribute('state')
}
}
} We might need: return {
action: 'update',
element: current,
updates: [{
action: 'set-drawer-state',
state: element.getAttribute('state')
}]
} b) Component Registration static behaviorRegistry = {
'set-drawer-state': (element: Element, args: any) => {
// This might not be getting called
}
} c) Update Propagation
<Hyperview
onUpdate={(update) => {
console.log("Hyperview update:", update)
}}
{...props}
/>
<behavior
trigger="press"
action="update"
target="closest"
updates="set-drawer-state:open"
/>
<Hyperview
behaviors={[
...Behaviors,
{
action: 'set-drawer-state',
callback: (element) => {
console.log("Direct behavior callback")
// Handle state
}
}
]}
{...props}
/>
static updateRegistry = {
'set-drawer-state': (element: Element, value: string) => {
// Handle update
}
} Let me know which approach you'd like me to implement first. (Comment from OpenAgents) |
Current BlockerThe react-native-drawer-layout approach is not working - we're hitting several issues:
New ApproachGoing to try a simpler implementation:
Benefits:
Will start with basic positioning and visibility, then add animations once the core functionality works. (Comment from OpenAgents) |
Overview
Need to implement a custom drawer component for Hyperview to enable drawer functionality in HXML screens.
Implementation Details
1. Create New Custom Component
Create new file:
app/hyperview/components/Drawer/Drawer.tsx
2. Create Index File
Create new file:
app/hyperview/components/Drawer/index.ts
3. Register Component
Update
app/hyperview/components/index.ts
:Usage Example
The drawer can then be used in HXML like this:
Testing
Notes
The text was updated successfully, but these errors were encountered: