diff --git a/app/components/PacksList.svelte b/app/components/PacksList.svelte index 7965201..e4bf72b 100644 --- a/app/components/PacksList.svelte +++ b/app/components/PacksList.svelte @@ -828,8 +828,27 @@ type: 'image', image: story.thumbnail, name: story.name, + episode: story.episode, + episodeCount: thePack.extra?.episodeCount, subtitle: formatDuration(story.duration), - story + story, + onDraw: (item, event) => { + if (item.episode && item.episodeCount) { + textPaint.color = colorOnTertiaryContainer; + textPaint.fontWeight = 'bold'; + const canvas = event.canvas; + const h = canvas.getHeight(); + const w = canvas.getWidth(); + const staticLayout = new StaticLayout(` ${item.episode}/${item.episodeCount} `, textPaint, w, LayoutAlignment.ALIGN_NORMAL, 1, 0, false); + const width = staticLayout.getLineWidth(0); + const height = staticLayout.getHeight(); + canvas.translate(24, h - height - 10); + textPaint.setColor(colorTertiaryContainer); + canvas.drawRoundRect(-4, -1, width + 4, height + 1, height / 2, height / 2, textPaint); + textPaint.color = colorOnTertiaryContainer; + staticLayout.draw(canvas); + } + } })) }); if (data?.story) { diff --git a/app/components/common/ListItem.svelte b/app/components/common/ListItem.svelte index fd26fe4..f79192d 100644 --- a/app/components/common/ListItem.svelte +++ b/app/components/common/ListItem.svelte @@ -2,7 +2,8 @@ import { Canvas, CanvasView } from '@nativescript-community/ui-canvas'; import { createEventDispatcher } from '@shared/utils/svelte/ui'; import { colors, fontScale, fonts } from '~/variables'; - $: ({ colorOnSurface, colorOnSurfaceVariant, colorPrimary, colorOutlineVariant } = $colors); + import { ListItem } from './ListItem'; + $: ({ colorOnSurface, colorOnSurfaceVariant, colorOutlineVariant, colorPrimary } = $colors); const dispatch = createEventDispatcher(); // technique for only specific properties to get updated on store change export let showBottomLine: boolean = false; @@ -11,25 +12,38 @@ export let fontSize: number = 17; export let fontWeight: string | number = 500; export let subtitleFontSize: number = 14; - export let title: string = null; - export let subtitle: string = null; - export let leftIcon: string = null; export let columns: string = '*'; export let mainCol = 0; export let leftIconFonFamily: string = $fonts.mdi; - export let color: string = colorOnSurface; - export let subtitleColor: string = null; - export let onDraw: (event: { canvas: Canvas; object: CanvasView }) => void = null; + // export let color: string = colorOnSurface; + // export let subtitleColor: string = null; + export let item: ListItem; + export let onDraw: (item: ListItem, event: { canvas: Canvas; object: CanvasView }) => void = null; - dispatch('tap', event)} {...$$restProps}> - - - + dispatch('tap', event)} {...$$restProps}> + { + (item.onDraw || onDraw)?.(item, event); + }}> + + - - - + + + diff --git a/app/components/common/ListItem.ts b/app/components/common/ListItem.ts new file mode 100644 index 0000000..eaf35b5 --- /dev/null +++ b/app/components/common/ListItem.ts @@ -0,0 +1,19 @@ +import { Canvas, CanvasView } from "@nativescript-community/ui-canvas"; + +export interface ListItem { + iconFontSize?: number; + subtitleFontSize?: number; + rightValue?: string | (() => string); + rightValueFontSize?: number; + fontSize?: number; + html?: any; + name?: string; + icon?: string; + color?: string | Color; + rippleColor?: string | Color; + title?: string; + subtitle?: string; + type?: string; + onDraw?: (item: ListItem, event: { canvas: Canvas; object: CanvasView }) => void; + [k: string]: any; +} diff --git a/app/components/common/ListItemAutoSize.svelte b/app/components/common/ListItemAutoSize.svelte index cee8443..d731081 100644 --- a/app/components/common/ListItemAutoSize.svelte +++ b/app/components/common/ListItemAutoSize.svelte @@ -1,8 +1,8 @@ @@ -10,30 +10,20 @@ diff --git a/app/components/common/ListItemAutoSizeFull.svelte b/app/components/common/ListItemAutoSizeFull.svelte index 2dba290..c734f06 100644 --- a/app/components/common/ListItemAutoSizeFull.svelte +++ b/app/components/common/ListItemAutoSizeFull.svelte @@ -1,8 +1,8 @@ @@ -10,8 +10,8 @@ - diff --git a/app/components/common/OptionSelect.svelte b/app/components/common/OptionSelect.svelte index ec8d761..e6ae469 100644 --- a/app/components/common/OptionSelect.svelte +++ b/app/components/common/OptionSelect.svelte @@ -4,18 +4,19 @@ import { CheckBox } from '@nativescript-community/ui-checkbox'; import { openFilePicker } from '@nativescript-community/ui-document-picker'; import { closeBottomSheet } from '@nativescript-community/ui-material-bottomsheet/svelte'; + import { TextField } from '@nativescript-community/ui-material-textfield'; import { EventData, File, ObservableArray, Utils, View } from '@nativescript/core'; import { debounce } from '@nativescript/core/utils'; import { onDestroy } from 'svelte'; import { Template } from 'svelte-native/components'; import IconButton from '~/components/common/IconButton.svelte'; import ListItem from '~/components/common/ListItem.svelte'; + import { ListItem as IListItem } from '~/components/common/ListItem'; import { lc } from '~/helpers/locale'; - import { actionBarButtonHeight, colors } from '~/variables'; + import { colors } from '~/variables'; import ListItemAutoSize from './ListItemAutoSize.svelte'; - import { TextField } from '@nativescript-community/ui-material-textfield'; - export interface OptionType { - name: string; + export interface OptionType extends IListItem { + subtitle?: string; isPick?: boolean; boxType?: string; type?: string; @@ -37,9 +38,6 @@ export let fontWeight = 'bold'; export let options: OptionType[] | ObservableArray; export let onClose = null; - export let titleProps: Partial = {}; - export let titleHolderProps: Partial = {}; - export let subtitleProps: Partial = {}; export let selectedIndex = -1; export let height: number | string = null; export let fontSize = 16; @@ -48,10 +46,17 @@ export let currentlyCheckedItem = null; export let onCheckBox: (item, value, e) => void = null; export let onRightIconTap: (item, e) => void = null; + + export let titleProps: Partial = {}; + export let titleHolderProps: Partial = {}; + export let subtitleProps: Partial = {}; + export let templateProps: Partial & { + [k: string]: Partial; + } = {}; + export let component = autoSizeListItem ? ListItemAutoSize : ListItem; let filteredOptions: OptionType[] | ObservableArray = null; let filter: string = null; - DEV_LOG && console.log('titleProps', titleProps); // technique for only specific properties to get updated on store change $: ({ colorOutline } = $colors); @@ -226,19 +231,17 @@ onTap(item, event)}> onTap(item, event)}> onRightTap(item, event)} /> @@ -274,20 +275,18 @@ onTap(item, event)}> @@ -296,18 +295,15 @@ onRightTap(item, event)} on:tap={(event) => onTap(item, event)}>