Skip to content

Commit

Permalink
Merge pull request #83 from ipuppet/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ipuppet authored Oct 4, 2022
2 parents 4ab18db + 94d7581 commit 66b6455
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 45 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"info": {
"name": "CAIO",
"version": "1.6.7",
"version": "1.6.8",
"author": "ipuppet",
"module": false
},
Expand Down
2 changes: 1 addition & 1 deletion dist/CAIO-en.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CAIO-zh-Hans.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CAIO.js

Large diffs are not rendered by default.

39 changes: 23 additions & 16 deletions scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class AppKernel extends Kernel {
settingMethods(this)
}

addOpenInJsboxButton() {
this.useJsboxNav()
this.setNavButtons([
{
image: $image("assets/icon.png"),
handler: () => this.openInJsbox()
}
])
}

initComponents() {
// Clipboard
this.clipboard = new Clipboard(this)
Expand Down Expand Up @@ -71,18 +81,9 @@ class AppUI {
static renderMainUI() {
const kernel = new AppKernel()
const buttons = {
clipboard: {
icon: "doc.on.clipboard",
title: $l10n("CLIPBOARD")
},
actions: {
icon: "command",
title: $l10n("ACTIONS")
},
setting: {
icon: "gear",
title: $l10n("SETTING")
}
clipboard: { icon: "doc.on.clipboard", title: $l10n("CLIPBOARD") },
actions: { icon: "command", title: $l10n("ACTIONS") },
setting: { icon: "gear", title: $l10n("SETTING") }
}
kernel.setting.setEvent("onSet", key => {
if (key === "mainUIDisplayMode") {
Expand Down Expand Up @@ -123,8 +124,8 @@ class AppUI {
kernel.tabBarController
.setPages({
clipboard: clipboardNavigationView.getPage(),
actions: kernel.actionManager.getPageView(),
setting: kernel.setting.getPageView()
actions: kernel.actionManager.getPage(),
setting: kernel.setting.getPage()
})
.setCells({
clipboard: buttons.clipboard,
Expand All @@ -138,16 +139,22 @@ class AppUI {

static renderKeyboardUI() {
const kernel = new AppKernel()
kernel.addOpenInJsboxButton()

const Keyboard = require("./ui/keyboard")
const keyboard = new Keyboard(kernel)
$ui.render({ views: [keyboard.getView()] })

kernel.UIRender(keyboard.getView())
}

static renderTodayUI() {
const kernel = new AppKernel()
kernel.addOpenInJsboxButton()

const Today = require("./ui/today")
const today = new Today(kernel)
$ui.render({ views: [today.getView()] })

kernel.UIRender(today.getView())
}

static renderUnsupported() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/libs/easy-jsbox.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions scripts/ui/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Clipboard {

/**
* 警告!该方法可能消耗大量资源
* @param {String} uuid
* @param {string} uuid
*/
getIndexPathByUUID(uuid) {
const data = $(this.listId).data
Expand Down Expand Up @@ -366,8 +366,10 @@ class Clipboard {

/**
* 将from位置的元素移动到to位置
* @param {Number} from
* @param {Number} to
* @param {number} from
* @param {number} to
* @param {number} section
* @param {boolean} copiedIndex
*/
move(from, to, section, copiedIndex = true) {
if (from === to) return
Expand Down Expand Up @@ -560,7 +562,7 @@ class Clipboard {
* 复制
* @param {*} text
* @param {*} uuid
* @param {Number} index 被复制的行的索引
* @param {number} index 被复制的行的索引
*/
copy(text, uuid, indexPath) {
const path = this.kernel.storage.keyToPath(text)
Expand Down Expand Up @@ -831,6 +833,7 @@ class Clipboard {
data: this.savedClipboard,
template: this.listTemplate(),
reorder: true,
crossSections: false,
actions: [
{
// 删除
Expand Down
2 changes: 1 addition & 1 deletion scripts/ui/components/action-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ class ActionManager {
return this.matrix.definition
}

getPageView() {
getPage() {
const navigationView = new NavigationView()
navigationView.navigationBarItems.setRightButtons(this.getNavButtons())
navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n("ACTIONS"))
Expand Down
14 changes: 6 additions & 8 deletions scripts/ui/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ class Keyboard extends Clipboard {
data.info.info.type,
data.info.info.dir
)
setTimeout(
() =>
action({
text: $clipboard.text
}),
500
)
$delay(0.5, () => action({ text: $clipboard.text }))
}
}
)
Expand Down Expand Up @@ -163,8 +157,12 @@ class Keyboard extends Clipboard {
pullDown: true,
items: [
{
title: "Next Keyboard",
title: $l10n("SWITCH_KEYBOARD"),
handler: this.keyboardTapped(() => $keyboard.next())
},
{
title: $l10n("OPEN_IN_JSBOX"),
handler: () => this.kernel.openInJsbox()
}
]
}
Expand Down
38 changes: 27 additions & 11 deletions scripts/ui/today.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { UIKit, BarButtonItem, NavigationBarItems, NavigationBar } = require("../libs/easy-jsbox")
const { View, UIKit, BarButtonItem, NavigationBarItems, NavigationBar } = require("../libs/easy-jsbox")
const Clipboard = require("./clipboard")
const TodayActions = require("./components/today-actions")

Expand Down Expand Up @@ -293,15 +293,17 @@ class Today extends Clipboard {
}
}

getMatrixView() {
getActionView() {
let data = this.todayActions.getActions()
if (data.length === 0) {
data = this.todayActions.getAllActions()
}
return {

const matrixView = {
type: "matrix",
props: {
id: this.matrixId,
bgcolor: $color("clear"),
columns: 2,
itemHeight: 50,
spacing: 8,
Expand Down Expand Up @@ -375,16 +377,14 @@ class Today extends Clipboard {
}
}
}
}

getActionView() {
return {
type: "view",
props: {
id: this.actionsId,
hidden: this.tabIndex !== 2
},
views: [this.getMatrixView()],
views: [matrixView],
layout: (make, view) => {
make.top.equalTo(this.navHeight)
make.bottom.left.right.equalTo(view.super.safeArea)
Expand All @@ -393,11 +393,27 @@ class Today extends Clipboard {
}

getView() {
return {
type: "view",
views: [this.getNavBarView(), this.getListView(), this.getActionView()],
layout: $layout.fill
}
// 直接放最外层 ready 事件不生效
return View.createFromViews([
{
type: "view",
views: [this.getNavBarView(), this.getListView(), this.getActionView()],
layout: $layout.fill,
events: {
ready: async () => {
if ($app.env !== $env.today) return

await $thread.main(0.5)
$ui.animate({
duration: 0.2,
animation: () => {
$ui.vc.runtimeValue().$view().$setBackgroundColor($color("clear"))
}
})
}
}
}
])
}
}

Expand Down
2 changes: 2 additions & 0 deletions strings/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"JSBOX_TOOLBAR" = "JSBox Toolbar";
"QUICK_START_SCRIPTS" = "Quick Start Scripts";
"SEND" = "Send";
"OPEN_IN_JSBOX" = "Open in JSBox";
"SWITCH_KEYBOARD" = "Switch Keyboard";

"CHECK_UPDATE" = "Check Update";
"UPDATE" = "Update";
Expand Down
2 changes: 2 additions & 0 deletions strings/zh-Hans.strings
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"JSBOX_TOOLBAR" = "JSBox 工具栏";
"QUICK_START_SCRIPTS" = "快速启动脚本";
"SEND" = "发送";
"OPEN_IN_JSBOX" = "在 JSBox 中打开";
"SWITCH_KEYBOARD" = "切换键盘";

"CHECK_UPDATE" = "检查更新";
"UPDATE" = "更新";
Expand Down

0 comments on commit 66b6455

Please sign in to comment.