Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/common/constants/store.key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import type {
FetchedWeather,
WeatherSettings,
} from '@/layouts/widgets/weather/weather.interface'
import type { ClockSettings } from '@/layouts/widgets/wigi-pad/clock-display/clock-setting.interface'
import type { WigiPadDateSetting } from '@/layouts/widgets/wigi-pad/date-display/date-setting.interface'
import type { ClockSettings } from '@/layouts/widgets/clock/clock-setting.interface'
import type { ExtensionConfigResponse } from '@/services/config-data/config-data.api'
import type { FetchedCurrency } from '@/services/hooks/currency/get-currency-by-code.hook'
import type { RecommendedSite, TrendItem } from '@/services/hooks/trends/get-trends.hook'
Expand Down Expand Up @@ -65,7 +64,6 @@ export interface StorageKV {
recent_searches: any
pets: PetSettings
clock: ClockSettings
wigiPadDate: WigiPadDateSetting
configData: ExtensionConfigResponse
toolsTab: ToolsTabType
comboTabs: ComboTabType
Expand Down
6 changes: 2 additions & 4 deletions src/common/utils/call-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { Bookmark } from '@/layouts/bookmark/types/bookmark.types'
import type { PetBackgroundId, PetTypes } from '@/layouts/widgets/pet/types'
import type { WigiNewsSetting } from '@/layouts/widgets/news/rss.interface'
import type { WeatherSettings } from '@/layouts/widgets/weather/weather.interface'
import type { ClockSettings } from '@/layouts/widgets/wigi-pad/clock-display/clock-setting.interface'
import type { WigiPadDateSetting } from '@/layouts/widgets/wigi-pad/date-display/date-setting.interface'
import type { ClockSettings } from '@/layouts/widgets/clock/clock-setting.interface'
import type { WidgetTabKeys } from '@/layouts/widgets-settings/tab-keys'
import type { StoredWallpaper, Wallpaper } from '../wallpaper.interface'
import type { Todo } from '@/services/hooks/todo/todo.interface'
Expand Down Expand Up @@ -54,8 +53,7 @@ export interface EventName {
}

// setting keys
wigiPadDateSettingsChanged: WigiPadDateSetting
wigiPadClockSettingsChanged: ClockSettings
clockSettingsChanged: ClockSettings
currencies_updated: {
currencies: string[]
colorMode: CurrencyColorMode
Expand Down
1 change: 0 additions & 1 deletion src/layouts/widgets-settings/tab-keys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum WidgetTabKeys {
widget_management = 'widget_management',
wigiPad = 'wigiPad',
wigiArz = 'wigiArz',
news_settings = 'news_settings',
weather_settings = 'weather_settings',
Expand Down
6 changes: 0 additions & 6 deletions src/layouts/widgets-settings/widget-settings-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { PetSettings } from '../widgets/pet/pet-setting'
import { RssFeedSetting } from '../widgets/news/rss-feed-setting'
import { WeatherSetting } from '../widgets/weather/weather-setting'
import { WigiArzSetting } from '../widgets/wigi-arz/wigi-arz-setting'
import { WigiPadSetting } from '../widgets/wigi-pad/wigi-pad-setting'
import { ComboSetting } from '../widgets/combo-widget/combo-setting'
import { WidgetTabKeys } from './tab-keys'

Expand Down Expand Up @@ -35,11 +34,6 @@ const WIDGET_SETTING_MODALS: Record<string, WidgetSettingModalConfig> = {
size: 'lg',
Component: RssFeedSetting,
},
[WidgetTabKeys.wigiPad]: {
title: 'تنظیمات ویجی پد',
size: 'lg',
Component: WigiPadSetting,
},
[WidgetTabKeys.combo_settings]: {
title: 'تنظیمات ویجت ترکیبی',
size: 'lg',
Expand Down
8 changes: 5 additions & 3 deletions src/layouts/widgets/__tests__/migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('migrateWidgetLayoutIfNeeded', () => {
it('migrates classic layout using activeWidgets with custom order', async () => {
storageMockData.appearance = { ui: 'CLASSIC' }
storageMockData.activeWidgets = [
{ id: WidgetKeys.weather, order: 2 },
{ id: WidgetKeys.todos, order: 2 },
{ id: WidgetKeys.calendar, order: 1 },
{ id: 'unknown-widget', order: 0 },
]
Expand All @@ -83,7 +83,9 @@ describe('migrateWidgetLayoutIfNeeded', () => {
expect(validateLayout(result, 8)).toBe(true)

const topWidgetKeys = [
WidgetKeys.wigiPad,
WidgetKeys.clock,
WidgetKeys.moodTracker,
WidgetKeys.weather,
WidgetKeys.search,
WidgetKeys.bookmarks,
WidgetKeys.photo,
Expand All @@ -96,7 +98,7 @@ describe('migrateWidgetLayoutIfNeeded', () => {
const bottomWidgets = result.filter((w) => !topWidgetKeys.includes(w.id))
expect(bottomWidgets.map((w) => w.id)).toEqual([
WidgetKeys.calendar,
WidgetKeys.weather,
WidgetKeys.todos,
])

expect(storageMockData.appearance.ui).toBe('CUSTOM')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ClockSettings {
showTimeZone: boolean
useSelectedFont: boolean
}

export enum ClockType {
Analog = 'analog',
Digital = 'digital',
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/widgets/clock/clock.widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { FetchedTimezone } from '@/services/hooks/timezone/get-timezones.ho
import {
type ClockSettings,
ClockType,
} from '../wigi-pad/clock-display/clock-setting.interface'
} from './clock-setting.interface'
import { WidgetContainer } from '../widget-container'
import type { WidgetSize } from '../layout-engine/types'
import { Clock1x1 } from './variants/clock-1x1'
Expand Down Expand Up @@ -41,7 +41,7 @@ export function ClockWidget({ size = { w: 2, h: 1 }, meta }: ClockWidgetProps) {
}
}

const event = listenEvent('wigiPadClockSettingsChanged', (data) => {
const event = listenEvent('clockSettingsChanged', (data) => {
setClockSettings({
clockType: data.clockType,
showSeconds: data.showSeconds,
Expand Down
25 changes: 13 additions & 12 deletions src/layouts/widgets/layout-engine/__tests__/layout-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ describe('Layout Engine Tests', () => {
size: { w: 4, h: 2 },
},
{
id: WidgetKeys.wigiPad,
instanceId: 'wigipad',
id: WidgetKeys.clock,
instanceId: 'clock',
position: { col: 0, row: 3 },
size: { w: 2, h: 2 },
},
Expand All @@ -102,16 +102,16 @@ describe('Layout Engine Tests', () => {
const result = resolveLayoutChange({
layout: initial,
operation: 'move',
instanceId: 'wigipad',
instanceId: 'clock',
targetPosition: { col: 0, row: 0 },
cols: 8,
})

expect(result).not.toBeNull()
expect(validateLayout(result!, 8)).toBe(true)

const wigipad = result!.find((w) => w.instanceId === 'wigipad')!
expect(wigipad.position).toEqual({ col: 0, row: 0 })
const clock = result!.find((w) => w.instanceId === 'clock')!
expect(clock.position).toEqual({ col: 0, row: 0 })
})

it('compacts layout removing vertical gaps', () => {
Expand Down Expand Up @@ -149,14 +149,16 @@ describe('Layout Engine Tests', () => {
expect(slot).toEqual({ col: 0, row: 1 })
})

it('contains 9 widgets in the default layout matching the Advanced layout', () => {
expect(DEFAULT_WIDGET_LAYOUT.length).toBe(9)
it('contains 11 widgets in the default layout matching the Advanced layout', () => {
expect(DEFAULT_WIDGET_LAYOUT.length).toBe(11)
const widgetIds = DEFAULT_WIDGET_LAYOUT.map((w) => w.id)
expect(widgetIds).toContain(WidgetKeys.photo)
expect(widgetIds).toContain(WidgetKeys.pet)
expect(widgetIds).toContain(WidgetKeys.search)
expect(widgetIds).toContain(WidgetKeys.bookmarks)
expect(widgetIds).toContain(WidgetKeys.wigiPad)
expect(widgetIds).toContain(WidgetKeys.clock)
expect(widgetIds).toContain(WidgetKeys.moodTracker)
expect(widgetIds).toContain(WidgetKeys.weather)
expect(widgetIds).toContain(WidgetKeys.calendar)
expect(widgetIds).toContain(WidgetKeys.yadKar)
expect(widgetIds).toContain(WidgetKeys.tools)
Expand All @@ -172,11 +174,10 @@ describe('Layout Engine Tests', () => {
size: { w: 4, h: 1 },
},
{
id: WidgetKeys.wigiPad,
instanceId: 'wigipad-default',
id: WidgetKeys.clock,
instanceId: 'clock-default',
position: { col: 0, row: 3 },
size: { w: 2, h: 4 },
meta: { variant: 'simplify' },
size: { w: 2, h: 2 },
},
{
id: WidgetKeys.bookmarks,
Expand Down
19 changes: 16 additions & 3 deletions src/layouts/widgets/layout-engine/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,23 @@ export const GRID_BREAKPOINTS: GridBreakpoint[] = [

export const DEFAULT_WIDGET_LAYOUT: StoredWidget[] = [
{
id: WidgetKeys.wigiPad,
instanceId: 'wigipad-default',
id: WidgetKeys.clock,
instanceId: 'clock-default',
position: { col: 0, row: 0 },
size: { w: 2, h: 3 },
size: { w: 2, h: 1 },
meta: { variant: 'digital' },
},
{
id: WidgetKeys.moodTracker,
instanceId: 'moodtracker-default',
position: { col: 0, row: 1 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.weather,
instanceId: 'weather-default',
position: { col: 0, row: 2 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.search,
Expand Down
1 change: 0 additions & 1 deletion src/layouts/widgets/layout-engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export enum WidgetKeys {
todos = 'todos',
tools = 'tools',
notes = 'notes',
wigiPad = 'wigiPad',
network = 'network',
yadKar = 'yadKar',
HabitTracker = 'HabitTracker',
Expand Down
21 changes: 17 additions & 4 deletions src/layouts/widgets/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ const DEFAULT_BOTTOM_WIDGETS: WidgetKeys[] = [

const topWidgets: StoredWidget[] = [
{
id: WidgetKeys.wigiPad,
instanceId: 'wigipad-default',
id: WidgetKeys.clock,
instanceId: 'clock-default',
position: { col: 0, row: 0 },
size: { w: 2, h: 3 },
size: { w: 2, h: 1 },
meta: { variant: 'digital' },
},
{
id: WidgetKeys.moodTracker,
instanceId: 'moodtracker-default',
position: { col: 0, row: 1 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.weather,
instanceId: 'weather-default',
position: { col: 0, row: 2 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.search,
Expand Down Expand Up @@ -127,7 +140,7 @@ export async function migrateWidgetLayoutIfNeeded(): Promise<StoredWidget[]> {

const bottomWidgets: StoredWidget[] = bottomKeys.map((key, index) => ({
id: key,
instanceId: `${key}-default`,
instanceId: `${key}-bottom-${index}`,
position: {
col: (index % 4) * 2,
row: 3 + Math.floor(index / 4) * 3,
Expand Down
19 changes: 16 additions & 3 deletions src/layouts/widgets/presets/preset-layouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ export const PRESET_LAYOUTS: PresetLayout[] = [
category: 'daily',
widgets: [
{
id: WidgetKeys.wigiPad,
instanceId: 'wigipad-default',
id: WidgetKeys.clock,
instanceId: 'clock-default',
position: { col: 0, row: 0 },
size: { w: 2, h: 3 },
size: { w: 2, h: 1 },
meta: { variant: 'digital' },
},
{
id: WidgetKeys.moodTracker,
instanceId: 'moodtracker-default',
position: { col: 0, row: 1 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.weather,
instanceId: 'weather-default',
position: { col: 0, row: 2 },
size: { w: 2, h: 1 },
},
{
id: WidgetKeys.search,
Expand Down
24 changes: 1 addition & 23 deletions src/layouts/widgets/widget-registry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { NewsLayout } from '@/layouts/widgets/news/news.widget'
import { ToolsLayout } from '@/layouts/widgets/tools/tools.widget'
import { WeatherLayout } from '@/layouts/widgets/weather/weather.widget'
import { WigiArzLayout } from '@/layouts/widgets/wigi-arz/wigi-arz.widget'
import { WigiPadWidget } from '@/layouts/widgets/wigi-pad/wigi-pad.widget'
import { YadkarWidget } from '@/layouts/widgets/yadkar/yadkar.widget'
import { HabitsLayout } from '@/layouts/widgets/habit/habit.widget'
import { CurrencyProvider } from '@/context/currency.context'
Expand Down Expand Up @@ -73,27 +72,6 @@ export const WIDGET_DEFINITIONS: Record<WidgetKeys, WidgetDefinition> = {
<PetWidget instanceId={instanceId} meta={meta} />
),
},
[WidgetKeys.wigiPad]: {
id: WidgetKeys.wigiPad,
label: 'ویجی‌پد',
emoji: '⏰',
category: 'time',
allowedSizes: [{ w: 2, h: 3 }],
defaultSize: { w: 2, h: 3 },
settingsTab: WidgetTabKeys.wigiPad,
canDuplicate: false,
variants: [
{
id: 'standard',
label: 'ویجی‌پد',
size: { w: 2, h: 3 },
meta: { variant: 'standard' },
},
],
node: (_instanceId, _size) => {
return <WigiPadWidget />
},
},
[WidgetKeys.clock]: {
id: WidgetKeys.clock,
label: 'ساعت',
Expand Down Expand Up @@ -222,7 +200,7 @@ export const WIDGET_DEFINITIONS: Record<WidgetKeys, WidgetDefinition> = {
canToggle: true,
allowedSizes: [
{ w: 1, h: 1, isVipOnly: true },
{ w: 2, h: 1, isVipOnly: true },
{ w: 2, h: 1 },
{ w: 2, h: 2, isVipOnly: true },
{ w: 2, h: 3 },
],
Expand Down
59 changes: 0 additions & 59 deletions src/layouts/widgets/wigi-pad/clock-display/clock-display.tsx

This file was deleted.

Loading
Loading