Skip to content

feat: 发现 筛选 #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2024
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
1 change: 1 addition & 0 deletions entry/src/main/ets/componets/common/sourceType.ets
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export default struct sourceType {
curve: CommonConstants.UniCurve
})
}
.padding({ top: 7 })
}
}
174 changes: 130 additions & 44 deletions entry/src/main/ets/componets/source/SourceCommon.ets
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,159 @@
*/
import ImageConstants from '../../common/constants/ImageConstants'
import PaddingConstants from '../../common/constants/PaddingConstants'
import { IconTitleVo } from '../../componetsmodel/IconTitleVo'
import dialogTitleFuction from '../common/dialogTitleFuction'
import noSourceFind from '../common/noSourceFind'
import { showMessage } from '../common/promptShow'
import { dataItem } from '../dataList/dataItem'
import { sourceTabs } from './sourceTabs'
import SourceView from './SourceView'
import { router } from '@kit.ArkUI'

@Component
@Preview
export default struct SourceCommon{
@State sourceList:dataItem[]=[
new dataItem("默认显示",12),
new dataItem("隐藏书源",12)
export default struct SourceCommon {
@Prop currentIndex: number
@State sourceList: dataItem[] = [
new dataItem("默认显示", 12),
new dataItem("隐藏书源", 12)
]
@Link showDialog: boolean
sourceController: TabsController = new TabsController();
@State @Watch('changeSourceIndex') readIndex: number = 0
@State showMoreDialog: boolean = false
@State searchValue: string = ''
@State isBatch: boolean = false

@State @Watch('changeSourceIndex')readIndex:number = 0
changeSourceIndex(){
changeSourceIndex() {
this.sourceController.changeIndex(this.readIndex)
}

build() {
Column(){
Column(){
Row({
space:12
}){
Search({
placeholder:'搜索书源'
})
.width('90%')
Image($r('app.media.more_vertical')).width(ImageConstants.IMG_WIDTH_24).height(ImageConstants.IMG_WIDTH_24)
.layoutWeight(1)
}
Column() {
Column() {
Stack() {
Column() {
Row({
space: 12
}) {
Search({
value: this.searchValue,
placeholder: '搜索书源'
})
.width('90%')
.onChange((value: string) => {
this.searchValue = value
// this.getList()
})

sourceTabs({
sourceList:this.sourceList,
read_index:this.readIndex
})
Image($r('app.media.more_vertical'))
.width(ImageConstants.IMG_WIDTH_24)
.height(ImageConstants.IMG_WIDTH_24)
.layoutWeight(1)
.bindMenu(
this.showMoreDialog,
this.rightDialogBuilder(this.More_Right_Dialog_Data, async (index: number) => {
switch (index) {
case 0:
case 1:
showMessage(this.More_Right_Dialog_Data[index].title);
break;
case 2:
this.showDialog = false
router.pushUrl({
url: 'pages/view/Find/BookSource/Index'
})
break;
case 3:
this.isBatch = true
break;
}
}),
{
onDisappear: () => {
this.showMoreDialog = false
}
})
.onClick(() => {
this.showMoreDialog = true
})
}

Tabs({
barPosition: BarPosition.Start,
controller: this.sourceController
}){
TabContent(){
this.sourceBuilder()
sourceTabs({
sourceList: this.sourceList,
read_index: this.readIndex
})
}
.align(Alignment.Top)
TabContent(){
Text('222')
.padding({
left: PaddingConstants.PADDING_20,
right: PaddingConstants.PADDING_20
})
.translate({ y: !this.isBatch ? 0 : -120 })
.animation({
duration: 500,
delay: 0
})
.zIndex(1)

Tabs({
barPosition: BarPosition.Start,
controller: this.sourceController
}) {
TabContent() {
SourceView({
searchValue: this.searchValue,
isBatch: this.isBatch,
type: this.currentIndex,
index: 0
})
}
.height('100%')
.align(Alignment.Top)

TabContent() {
SourceView({
searchValue: this.searchValue,
isBatch: this.isBatch,
type: this.currentIndex,
index: 1
})
}
.height('100%')
.align(Alignment.Top)
}
.align(Alignment.Top)
.barWidth(0)
.barHeight(0)
.scrollable(false)
.layoutWeight(1)
.padding({ top: this.isBatch ? 0 : 120 })
}
.barWidth(0)
.barHeight(0)
.scrollable(false)

.alignContent(Alignment.Top)
}
.padding({left:PaddingConstants.PADDING_20,right:PaddingConstants.PADDING_20})
.justifyContent(FlexAlign.Center)
}
.backgroundColor('#f5f5f5')
}

More_Right_Dialog_Data: IconTitleVo[] = [
new IconTitleVo($r('app.media.ic_folder'), '按时间排序'),
new IconTitleVo($r('app.media.icon_no_source_find'), '按评分排序'),
new IconTitleVo($r('app.media.add_book_shelf'), '书源管理'),
new IconTitleVo($r('app.media.icon_rule_batch'), '批量'),
]

@Builder
sourceBuilder(){
Flex({
justifyContent:FlexAlign.Center
}){
noSourceFind({
isShowButton:true,
title:'暂无书源'
rightDialogBuilder(list: IconTitleVo[], dialogRightChange: (_index: number) => void) {
Column() {
ForEach(list, (item: IconTitleVo, index) => {
dialogTitleFuction({
title: item.title,
icon: item.icon,
isBorder: list.length !== index + 1
})
.onClick(() => {
dialogRightChange(index)
})
})
}
}
Expand Down
Loading
Loading