Compare commits

...

2 Commits

10 changed files with 62 additions and 74 deletions

View File

@@ -1,67 +1,11 @@
import { View, Text } from 'react-native' import { View } from 'react-native'
import { Settings } from '@my/ui' import { Settings } from '@my/ui'
import type { SettingsItemProps } from '@my/ui' import { settings } from '@my/config'
export function SettingsScreen() { export function SettingsScreen() {
const appName = 'flexlark'
const version = 'dev 0.0.0'
const items: SettingsItemProps[] = [
{
id: 'notification',
label: '通知',
description: '通知内有关于通知的相关设置',
type: 'group',
options: {
children: [
{
id: 'enableNotification',
label: '是否通知',
description: '开启后将收到系统通知',
type: 'switch',
options: {},
},
{
id: 'notificationContent',
label: '通知内容',
description: '设置通知的内容',
type: 'input',
options: {},
},
],
},
},
{
id: 'about',
type: 'group',
label: '关于',
options: {
children: [
{
id: 'about-flexlark',
label: `关于灵动云雀`,
description: `我们是什么?`,
type: 'link',
options: {
url: 'https://flexlark.org/',
},
},
{
id: 'about-app',
label: `关于${appName}`,
description: `当前应用正在激烈开发中`,
type: 'alert',
options: {
message: `版本号:${version}`,
},
},
],
},
},
]
return ( return (
<View> <View>
<Settings items={items} /> <Settings items={settings} />
</View> </View>
) )
} }

View File

@@ -1 +1,2 @@
export * from './tamagui.config' export * from './tamagui.config'
export * from './settings'

View File

@@ -0,0 +1,48 @@
import { SettingsProps } from '@my/ui'
export const settings: SettingsProps['items'] = [
{
id: 'notification',
label: '通知',
description: '通知内有关于通知的相关设置',
type: 'group',
options: {
children: [
{
id: 'enableNotification',
label: '是否通知',
description: '开启后将收到系统通知',
type: 'switch',
options: {},
},
],
},
},
{
id: 'about',
type: 'group',
label: '关于',
options: {
children: [
{
id: 'about-flexlark',
label: `关于灵动云雀`,
description: `我们是什么?`,
type: 'link',
options: {
url: 'https://flexlark.org/',
},
},
{
id: 'about-app',
label: `关于灵动云雀`,
description: `当前应用正在激烈开发中`,
type: 'alert',
options: {
message: `版本号: bate v0.0.0`,
},
},
],
},
},
]

View File

@@ -11,7 +11,7 @@ import { SettingsGroup } from './items/SettingsGroup'
import { SettingsLink } from './items/SettingsLink' import { SettingsLink } from './items/SettingsLink'
export function SettingsItem(props: SettingsItemProps) { export function SettingsItem(props: SettingsItemProps) {
const { label, description, type } = props const { type } = props
const Component = settingsItemRander(type) const Component = settingsItemRander(type)
return <Component {...props} /> return <Component {...props} />
} }

View File

@@ -1,6 +1,6 @@
import { ListItem, Toast, useToastController, useToastState, YStack } from '@my/ui' import { ListItem, Toast, useToastController, useToastState, YStack } from '@my/ui'
import type { SettingsAlertOption, SettingsItemProps } from '@my/ui' import type { SettingsItemProps } from '@my/ui'
import { useCallback, useState } from 'react' import { useCallback } from 'react'
export interface SettingsAlertProps { export interface SettingsAlertProps {
title: string title: string

View File

@@ -1,6 +1,6 @@
import { ListItem, Toast, useToastController, useToastState, YStack } from '@my/ui' import { ListItem, Toast, useToastController, useToastState, YStack } from '@my/ui'
import type { SettingsAlertOption, SettingsItemProps } from '@my/ui' import type { SettingsItemProps } from '@my/ui'
import { useCallback, useState } from 'react' import { useCallback } from 'react'
export interface SettingsAlertProps { export interface SettingsAlertProps {
title: string title: string

View File

@@ -1,4 +1,4 @@
import { Button, Input, XStack, YStack, styled, Text, View } from '@my/ui' import { Button, Input, XStack, YStack, styled, Text } from '@my/ui'
import { withSettingsSheet, WithSettingsSheetProps } from './SettingsSheet' import { withSettingsSheet, WithSettingsSheetProps } from './SettingsSheet'
import { useState } from 'react' import { useState } from 'react'
import { settingsStore } from '../../store' import { settingsStore } from '../../store'
@@ -33,7 +33,7 @@ const Footer = styled(XStack, {
}) })
const SettingsInputComponent = (props: WithSettingsSheetProps<'input'>) => { const SettingsInputComponent = (props: WithSettingsSheetProps<'input'>) => {
const { label, icon, description, disabled, options, onClose } = props const { label, description, onClose } = props
const [value, setValue] = useState('') const [value, setValue] = useState('')
/** /**
* 确认按钮事件 * 确认按钮事件

View File

@@ -10,9 +10,7 @@ const Line = styled(Separator, {
marginVertical: '$4', marginVertical: '$4',
}) })
export const SettingsLine = (props: SettingsItemProps<'alert'>) => { export const SettingsLine = (_props: SettingsItemProps<'alert'>) => {
const { label } = props
return ( return (
<> <>
<Line alignSelf="stretch" /> <Line alignSelf="stretch" />

View File

@@ -8,6 +8,7 @@ export interface SettingsAlertProps {
} }
export const SettingsPage = (props: SettingsItemProps<'alert'>) => { export const SettingsPage = (props: SettingsItemProps<'alert'>) => {
// TODO 尚未完成开发
const { label, icon, description, disabled, options } = props const { label, icon, description, disabled, options } = props
const toast = useToastController() const toast = useToastController()

View File

@@ -1,11 +1,7 @@
import { ListItem, Sheet } from '@my/ui'
import type { SettingsItemProps } from '@my/ui'
import { useState } from 'react'
import { withSettingsSheet, WithSettingsSheetProps } from './SettingsSheet' import { withSettingsSheet, WithSettingsSheetProps } from './SettingsSheet'
const SettingsSelectComponent = (props: WithSettingsSheetProps<'select'>) => { const SettingsSelectComponent = (props: WithSettingsSheetProps<'select'>) => {
const { label, icon, description, disabled, options } = props // TODO 尚未完成开发
return <></> return <></>
} }