use children instead of items on Stacks (#240)

This commit is contained in:
end-4
2024-02-06 07:53:34 +07:00
parent 1d6623cb57
commit 0186fc016c
2 changed files with 15 additions and 4 deletions
+11 -3
View File
@@ -13,7 +13,8 @@ import Gemini from '../../services/gemini.js';
import { geminiView, geminiCommands, sendMessage as geminiSendMessage, geminiTabIcon } from './apis/gemini.js';
import { chatGPTView, chatGPTCommands, sendMessage as chatGPTSendMessage, chatGPTTabIcon } from './apis/chatgpt.js';
import { waifuView, waifuCommands, sendMessage as waifuSendMessage, waifuTabIcon } from './apis/waifu.js';
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
import { enableClickthrough } from '../../lib/roundedcorner.js';
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
const EXPAND_INPUT_THRESHOLD = 30;
@@ -141,6 +142,7 @@ const chatPlaceholderRevealer = Revealer({
transition: 'crossfade',
transitionDuration: 200,
child: chatPlaceholder,
setup: enableClickthrough,
});
const textboxArea = Box({ // Entry area
@@ -159,12 +161,18 @@ const textboxArea = Box({ // Entry area
const apiContentStack = Stack({
vexpand: true,
transition: 'slide_left_right',
items: APIS.map(api => [api.name, api.contentWidget]),
children: APIS.reduce((acc, api) => {
acc[api.name] = api.contentWidget;
return acc;
}, {}),
})
const apiCommandStack = Stack({
transition: 'slide_up_down',
items: APIS.map(api => [api.name, api.commandBar]),
children: APIS.reduce((acc, api) => {
acc[api.name] = api.commandBar;
return acc;
}, {}),
})
function switchToTab(id) {
+4 -1
View File
@@ -30,7 +30,10 @@ let currentTabId = 0;
export const contentStack = Stack({
vexpand: true,
transition: 'slide_left_right',
items: contents.map(item => [item.name, item.content]),
children: contents.reduce((acc, item) => {
acc[item.name] = item.content;
return acc;
}, {}),
})
function switchToTab(id) {