Copy link to clipboard
Copied
local LrView = import "LrView"
local LrDialogs = import "LrDialogs"
local logger = import "LrLogger"("test")
local LrFunctionContext = import "LrFunctionContext"
local LrTasks = import "LrTasks"
local LrBinding = import "LrBinding"
local LrColor = import "LrColor"
local LrHttp = import "LrHttp"
local f = LrView:osFactory()
logger:enable("logfile")
local function initTaskList(tasks)
local init_taskList = {}
for key, task in ipairs(tasks) do
table.insert( init_taskList,
f: view{
bind_to_object = task,
visible = LrView.bind "task_visible",
f: row{
margin_top = 16,
margin_left = 8,
f: view{
margin_top = 21,
f: checkbox{
margin_top = 20,
value = LrView.bind ("is_choose")
},
},
f: picture{
value = _PLUGIN:resourceId ("./default_cover.png")
},
f: column{
margin_top = 9,
spacing = 9,
f: static_text{
title = LrView.bind ("task_name")
},
f: static_text{
title = LrView.bind ("photo_count")
}
}
}
})
end
return init_taskList
end
local function initTasks()
local init_tasks = {}
for i=1, 20 do
table.insert( init_tasks, {
task_id = i,
task_visible = true,
is_choose = false,
picture = "",
task_name = i,
photo_count = "0 photos"
})
end
return init_tasks
end
local function UIMain()
LrFunctionContext.postAsyncTaskWithContext('UIMain', function(context)
local user = LrBinding.makePropertyTable(context)
user.tasks_view = true
user.searched = false
user.taskCount = 0
user.result = {}
user.tasks = initTasks()
user.taskList_view = initTaskList(user.tasks)
local function myCalledFunction()
local items = user.tasks
for key, value in ipairs(user.result) do
items[key].task_id = value.task_id
items[key].task_visible = true
items[key].task_name = value.task_name
items[key].photo_count = value.photo_count
end
user.tasks = items
end
user:addObserver('taskCount', myCalledFunction)
local showList = f: scrolled_view{
bind_to_object = tasks,
width = 730,
height = 310,
versical_scroller = true,
horizontal_scroller = false,
f: view(user.taskList_view)
}
local taskList = f: group_box{
title = "Task List",
font = "<system>",
show_title = true,
width = 754,
height = 387,
margin_top = 25,
margin_left = 12,
margin_bottom = 12,
f: row{
f: push_button{
title = "refresh",
action = function()
user.taskCount = user.taskCount + 1
table.insert(user.result, {
task_id = 123,
task_visible = true,
picture = "",
task_name = "test",
photo_count = "0 photos"
})
end
}
},
showList
}
local workSpace = f: view{
bind_to_object = user,
visible = LrView.bind "tasks_view",
f: tab_view {
height = 480,
width = 778,
f: tab_view_item{
title = "TaskServer",
identifier = "TaskServer",
taskList
},
f: tab_view_item{
title = "MoreInfo",
identifier = "MoreInfo"
}
}
}
local content = f: view{
width = 826,
height = 539,
margin_top = 33,
margin_bottom = 22,
margin_horizontal = 22,
place = "overlapping",
workSpace
}
LrDialogs.presentFloatingDialog(_PLUGIN, {
title = 'xxpie',
contents = content,
blockTask = true,
windowWillClose = function()
end
})
end)
end
UIMain()
First, I created a tasks and a taskList_view for instantiation. and each taskList_view bind each tasks object ,but I change the tasks ,the taskList_view would not change
Bold fonts are key
Have something to add?