Skip to content

Commit

Permalink
Merge pull request #209 from yi-boide/dev_172434
Browse files Browse the repository at this point in the history
feat: 发现 筛选
  • Loading branch information
MaoXiaoone authored Jul 20, 2024
2 parents eab7647 + 7b1e291 commit ebe9462
Show file tree
Hide file tree
Showing 4 changed files with 536 additions and 56 deletions.
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

0 comments on commit ebe9462

Please sign in to comment.