/* * Copyright 2012-2018 Morgan McMillian * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import bb.cascades 1.0 import "humane.js" as HumaneDate Container { id: taskItem Container { layout: StackLayout { } Container { layout: DockLayout { } horizontalAlignment: HorizontalAlignment.Fill leftPadding: 10.0 rightPadding: 10.0 topPadding: 10.0 Container { layout: StackLayout { orientation: LayoutOrientation.LeftToRight } Container { minWidth: 50.0 Label { text: ListItemData.priority textStyle.fontSize: FontSize.Large //textStyle.color: Color.Blue textStyle.color: getPriorityColor(ListItemData.priority) } } } Container { layout: StackLayout { } leftPadding: 40.0 Container { Label { text: ListItemData.detail multiline: true textStyle.fontSize: FontSize.Medium //textStyle.color: ListItemData.complete ? Color.Gray : Color.Black textStyle.color: getDetailColor(ListItemData.complete) } } Container { layout: StackLayout { orientation: LayoutOrientation.LeftToRight } topPadding: 5.0 Container { rightPadding: ListItemData.dateDue.length > 0 ? 10.0 : 0 Label { text: ListItemData.dateDue.length > 0 ? "Due " + HumaneDate.humaneDate(ListItemData.dateDue) : "" textStyle.fontSize: FontSize.XXSmall textStyle.color: Color.Gray textStyle.fontWeight: FontWeight.Bold } } Container { Label { text: ListItemData.complete ? "Completed " + HumaneDate.humaneDate(ListItemData.dateCompleted) : ListItemData.dateCreated ? "Created " + HumaneDate.humaneDate(ListItemData.dateCreated) : "" textStyle.fontSize: FontSize.XXSmall //textStyle.color: ListItemData.complete ? Color.LightGray : Color.Gray textStyle.color: Color.Gray } } } } } Divider { } } function getDetailColor(complete) { if (complete) return Color.Gray; switch (Application.themeSupport.theme.colorTheme.style) { case VisualStyle.Bright: return Color.Black; case VisualStyle.Dark: return Color.White; } return Color.Black; } function getPriorityColor(priority) { // TODO make each priority a different color switch (Application.themeSupport.theme.colorTheme.style) { case VisualStyle.Bright: return Color.Blue; case VisualStyle.Dark: return Color.Yellow; } return Color.Gray; } contextActions: [ ActionSet { title: ListItemData.detail ActionItem { title: "Edit" imageSource: "icons/Pencil.png" onTriggered: { editItem.open() editItem.newtask = false; editItem.text = ListItemData.text // editItem.pri = ListItemData.priority editItem.labels.removeAll(); for (var i = 0; i < taskItem.ListItem.view.dataModel.filters.length; i ++) { var o = opt.createObject(); o.text = taskItem.ListItem.view.dataModel.filters[i].title; o.value = taskItem.ListItem.view.dataModel.filters[i].title; editItem.labels.add(o); } editItem.textfield.requestFocus(); } } ActionItem { title: "Complete" imageSource: "icons/Check.png" enabled: ListItemData.complete ? false : true onTriggered: { taskItem.ListItem.view.dataModel.setValue(taskItem.ListItem.indexPath, "complete", true) } } ActionItem { title: "Undo Complete" imageSource: "icons/Undo.png" enabled: ListItemData.complete onTriggered: { taskItem.ListItem.view.dataModel.setValue(taskItem.ListItem.indexPath, "complete", false) } } InvokeActionItem { title: "Share" query { mimeType: "text/plain" invokeActionId: "bb.action.SHARE" } data: ListItemData.text } DeleteActionItem { title: "Delete" onTriggered: { taskItem.ListItem.view.dataModel.promptDelete(taskItem.ListItem.indexPath) } } } ] attachedObjects: [ EditSheet { id: editItem title: "Edit" taskitem: true onSaveTask: { taskItem.ListItem.view.dataModel.updateTask(taskItem.ListItem.indexPath, text) } }, ComponentDefinition { id: opt Option { } } ] }