-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MuxiKeStack:main' into main
- Loading branch information
Showing
14 changed files
with
1,595 additions
and
3,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.js linguist-language=typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
import { View } from '@tarojs/components'; | ||
import { memo } from 'react'; | ||
import { memo, useState } from 'react'; | ||
|
||
import Contact from './Contact'; | ||
import Selector from './Selector'; | ||
import Source from './Source'; | ||
|
||
const Guide: React.FC = memo(() => ( | ||
<View className="flex h-screen w-full flex-col items-center gap-4 overflow-y-scroll px-4 pb-[13vh] pt-2"> | ||
<Selector /> | ||
<Source /> | ||
<Contact /> | ||
</View> | ||
)); | ||
const Guide: React.FC = memo(() => { | ||
const [selection, setSelection] = useState<{ year: string; term: string }>({ | ||
year: '全部', | ||
term: '全部', | ||
}); | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
return ( | ||
<View className="flex h-screen w-full flex-col items-center gap-4 overflow-y-scroll px-4 pb-[13vh] pt-2"> | ||
<Selector | ||
selection={selection} | ||
isOpen={isOpen} | ||
setSelection={setSelection} | ||
setIsOpen={setIsOpen} | ||
> | ||
<Source year={selection.year} term={selection.term} /> | ||
<Contact /> | ||
</Selector> | ||
</View> | ||
); | ||
}); | ||
|
||
export default Guide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,96 @@ | ||
import { ConfigProvider, Picker, Popup } from '@taroify/core'; | ||
import { ArrowDown } from '@taroify/icons'; | ||
import { Text, View } from '@tarojs/components'; | ||
import { memo } from 'react'; | ||
|
||
interface SelectorProps {} | ||
|
||
const Selector: React.FC<SelectorProps> = memo(() => { | ||
return ( | ||
<View className="flex w-full items-center justify-between px-2"> | ||
<View className="flex w-1/3 flex-col gap-2"> | ||
<Text className="pl-2 text-xs">选择学年</Text> | ||
<View className="flex w-full justify-between rounded-lg bg-[#f9f9f2] px-2 py-1"> | ||
<Text className="text-xs">全部</Text> | ||
<ArrowDown className="text-xs" style={{ color: '#f18900' }} /> | ||
</View> | ||
</View> | ||
<View className="flex w-1/3 flex-col gap-2"> | ||
<Text className="pl-2 text-xs">选择学期</Text> | ||
<View className="flex w-full justify-between rounded-lg bg-[#f9f9f2] px-2 py-1"> | ||
<Text className="text-xs">全部</Text> | ||
<ArrowDown className="text-xs" style={{ color: '#f18900' }} /> | ||
</View> | ||
</View> | ||
import uniqueKeyUtil from '@/common/utils/keyGen'; | ||
|
||
type SelectType = '学年' | '学期'; | ||
|
||
interface SelectProps { | ||
type: SelectType; | ||
value: string; | ||
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
interface SelectorProps { | ||
selection: { year: string; term: string }; | ||
isOpen: boolean; | ||
setSelection: React.Dispatch<React.SetStateAction<{ year: string; term: string }>>; | ||
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; | ||
children: React.ReactNode; | ||
} | ||
|
||
const Times = () => { | ||
const startYear = 2022; | ||
const date = new Date(); | ||
const currentYear = | ||
date.getMonth() + 1 > 8 ? date.getFullYear() : date.getFullYear() - 1; | ||
|
||
return [ | ||
[ | ||
{ label: '全部', value: '全部' }, | ||
...Array(currentYear - startYear + 1) | ||
.fill(null) | ||
.map((_, index) => ({ | ||
label: `${startYear + index}`, | ||
value: `${startYear + index}`, | ||
})), | ||
], | ||
[ | ||
{ label: '全部', value: '全部' }, | ||
{ label: '第一学期', value: '第一学期' }, | ||
{ label: '第二学期', value: '第二学期' }, | ||
{ label: '第三学期', value: '第三学期' }, | ||
], | ||
]; | ||
}; | ||
|
||
const Select: React.FC<SelectProps> = memo(({ type, value, setIsOpen }) => ( | ||
<View className="flex w-1/3 flex-col gap-2"> | ||
<Text className="pl-2 text-xs">选择{type}</Text> | ||
<View | ||
className="flex w-full justify-between rounded-lg bg-[#f9f9f2] px-2 py-1" | ||
onClick={() => setIsOpen(true)} | ||
> | ||
<Text className="text-xs">{value}</Text> | ||
<ArrowDown className="text-xs" style={{ color: '#f18900' }} /> | ||
</View> | ||
); | ||
}); | ||
</View> | ||
)); | ||
|
||
const Selector: React.FC<SelectorProps> = memo( | ||
({ selection, isOpen, setSelection, setIsOpen, children }) => ( | ||
<> | ||
<View className="flex w-full items-center justify-between px-2"> | ||
{['学年', '学期'].map((item: SelectType) => ( | ||
<Select | ||
key={uniqueKeyUtil.nextKey()} | ||
type={item} | ||
value={item === '学年' ? selection.year : selection.term} | ||
setIsOpen={setIsOpen} | ||
/> | ||
))} | ||
</View> | ||
{children} | ||
<Popup open={isOpen} placement="bottom"> | ||
<Popup.Close /> | ||
<ConfigProvider theme={{ pickerConfirmActionColor: '#f18900' }}> | ||
<Picker | ||
style={{ marginBottom: '15vh' }} | ||
defaultValue={['全部', '全部']} | ||
title="选择学年和学期" | ||
columns={Times()} | ||
onConfirm={(value) => { | ||
setSelection({ year: value[0], term: value[1] }); | ||
setIsOpen(false); | ||
}} | ||
onCancel={() => setIsOpen(false)} | ||
/> | ||
</ConfigProvider> | ||
</Popup> | ||
</> | ||
) | ||
); | ||
|
||
export default Selector; |
Oops, something went wrong.