import{_ as s,o as n,c as a,e as l}from"./app--CGKFO0X.js";const e={},o=l(`<h1 id="展望未来" tabindex="-1"><a class="header-anchor" href="#展望未来" aria-hidden="true">#</a> 展望未来</h1><blockquote><p>未来是美好的，也是不确定的，让我们共同期待 <code>Hikage</code> 在未来的发展空间。</p></blockquote><h2 id="未来的计划" tabindex="-1"><a class="header-anchor" href="#未来的计划" aria-hidden="true">#</a> 未来的计划</h2><blockquote><p>这里收录了 <code>Hikage</code> 可能会在后期添加的功能。</p></blockquote><h3 id="处理-attrtibuteset" tabindex="-1"><a class="header-anchor" href="#处理-attrtibuteset" aria-hidden="true">#</a> 处理 AttrtibuteSet</h3><p><code>Hikage</code> 未来将会支持处理 <code>AttributeSet</code> 来对接 XML 原始的属性以实现接管一些并未在代码中对布局属性开放自定义的第三方组件。</p><p><code>Hikage</code> 目前已经支持自动化创建 <code>XmlBlock</code>，但尚未支持直接处理自定义的 <code>AttributeSet</code>，因为其历史遗留问题和处理难度较高，可能会折中考虑后期是否要继续完善此功能。</p><blockquote><p>示例如下</p></blockquote><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#DCBDFB;">TextView</span><span style="color:#ADBAC7;">(</span></span>
<span class="line"><span style="color:#ADBAC7;">    id </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;text_view&quot;</span><span style="color:#ADBAC7;">,</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// 通过 AttributeSet 传入的属性</span></span>
<span class="line"><span style="color:#ADBAC7;">    attrs </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#DCBDFB;">namespace</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;android&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#F47067;">set</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;text&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;Hello, World!&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#F47067;">set</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;textSize&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;16sp&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#F47067;">set</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;gravity&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#96D0FF;">&quot;center&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// 通过代码传入的属性</span></span>
<span class="line"><span style="color:#ADBAC7;">    text </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;Hello, World!&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">    textSize </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">16f</span></span>
<span class="line"><span style="color:#ADBAC7;">    gravity </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> Gravity.CENTER</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="生成组件-id" tabindex="-1"><a class="header-anchor" href="#生成组件-id" aria-hidden="true">#</a> 生成组件 ID</h3><p><code>Hikage</code> 未来可能会根据需求支持生成使用字符串自定义的组件 ID 的直接调用功能。</p><blockquote><p>示例如下</p></blockquote><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MyLayout</span><span style="color:#ADBAC7;"> : </span><span style="color:#F69D50;">HikageBuilder</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">build</span><span style="color:#ADBAC7;">() </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">Hikageable</span><span style="color:#ADBAC7;">(context) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#DCBDFB;">LinearLayout</span><span style="color:#ADBAC7;">(</span></span>
<span class="line"><span style="color:#ADBAC7;">            id </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;lin_layout&quot;</span><span style="color:#ADBAC7;">,</span></span>
<span class="line"><span style="color:#ADBAC7;">            lparams </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">LayoutParams</span><span style="color:#ADBAC7;">(matchParent </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span><span style="color:#ADBAC7;">),</span></span>
<span class="line"><span style="color:#ADBAC7;">            init </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">                orientation </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> LinearLayout.VERTICAL</span></span>
<span class="line"><span style="color:#ADBAC7;">                gravity </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> Gravity.CENTER</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        ) {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#DCBDFB;">TextView</span><span style="color:#ADBAC7;">(id </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;text_view&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">                text </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;Hello, World!&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                textSize </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">16f</span></span>
<span class="line"><span style="color:#ADBAC7;">                gravity </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> Gravity.CENTER</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> context: </span><span style="color:#F69D50;">Context</span></span>
<span class="line"><span style="color:#768390;">// 创建 TypedHikage</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> myLayout </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> MyLayout.</span><span style="color:#DCBDFB;">asTyped</span><span style="color:#ADBAC7;">().</span><span style="color:#DCBDFB;">build</span><span style="color:#ADBAC7;">().</span><span style="color:#DCBDFB;">create</span><span style="color:#ADBAC7;">(context)</span></span>
<span class="line"><span style="color:#768390;">// 或者，使用懒加载</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> myLayout </span><span style="color:#F47067;">by</span><span style="color:#ADBAC7;"> context.</span><span style="color:#DCBDFB;">lazyTypedHikage</span><span style="color:#ADBAC7;">(MyLayout)</span></span>
<span class="line"><span style="color:#768390;">// 直接调用根据字符串生成的 ID</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> linLayout </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> myLayout.linLayout</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> textView </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> myLayout.textView</span></span>
<span class="line"><span style="color:#768390;">// 获取根布局，即 LinearLayout</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> root </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> myLayout.root</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,13),p=[o];function t(c,i){return n(),a("div",null,p)}const y=s(e,[["render",t],["__file","future.html.vue"]]);export{y as default};
