Skip to content

Commit

Permalink
Merge pull request #18 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
添加宫格样式、下拉刷新
  • Loading branch information
MaoXiaoone authored May 5, 2024
2 parents c3fffd4 + 8fa8ab5 commit ea969f2
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 86 deletions.
146 changes: 108 additions & 38 deletions entry/src/main/ets/componets/IndexShelf.ets
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@ export default struct IndexShelf {

@State currentIndex: number = 0
THEME_NAMES: string[] = ['书籍导入', '下载管理', '导入书单','批量管理']
EXHIBIT_NAMES: string[] = ['列表', '宫格']
GROUP_NAMES:string[] = ['标签', '文件夹']
@State EXHIBIT:string = '宫格'
@State GROUP:string = '标签'
@State searchValue:string = '最近阅读'
@State bookType:string = '全部'
@State title:string = '最近阅读'
@State isClear:boolean = false
@State isRefreshing: boolean = false
@State counter: number = 0
@State RefreshingTitle:string = '松开刷新'
@State isShowCheck:boolean = false

build() {
Column() {
Flex({
Expand Down Expand Up @@ -115,31 +124,28 @@ export default struct IndexShelf {
}
){
Scroll(){
Row({space:16}){
IndexSearchType({title:this.title,searchValue:this.searchValue})
IndexSearchType({title:'浏览历史',searchValue:this.searchValue})
.onClick(()=> {
this.searchValue = '浏览历史'
})
if (this.searchValue !== '浏览历史') {
IndexSearchType({ title: '文件夹', searchValue: this.searchValue })
.onClick(() => {
this.searchValue = '文件夹'
})
IndexSearchType({ title: '宫格', searchValue: this.searchValue })
.onClick(() => {
this.searchValue = '宫格'
})
Divider()
.vertical(true)
.height(15)
.color('#989797')
.opacity(0.5)
.strokeWidth(1)
IndexSearchType({ title: '管理', searchValue: this.searchValue })
.onClick(() => {
this.searchValue = '管理'
Flex({
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.SpaceBetween
}){
Row({space:15}){
IndexSearchType({title:this.title,searchValue:this.searchValue})
IndexSearchType({title:'浏览历史',searchValue:this.searchValue})
.onClick(()=> {
this.searchValue = '浏览历史'
this.isShowCheck = false
})
if (this.searchValue !== '浏览历史') {
this.GroupBuilder()
this.ExhibitBuilder()
Text('管理')
.fontColor('rgba(0,0,0,0.5)')
.fontSize(15)
.fontWeight(400)
.onClick(()=>{
this.isShowCheck = !this.isShowCheck
})
}
}
}
}
Expand Down Expand Up @@ -219,22 +225,74 @@ export default struct IndexShelf {
)
}.margin({ left: 15,bottom:10})
}

Scroll(){
Stack({alignContent:Alignment.Center}) {
if (this.currentIndex === 0){
novelPage({searchValue:this.searchValue,currentIndex:0,isClear:this.isClear}).zIndex(0)
} else if(this.currentIndex === 1) {
cartoonPage({searchValue:this.searchValue,currentIndex:1,isClear:this.isClear}).zIndex(1)
} else if(this.currentIndex === 2) {
soundPage({searchValue:this.searchValue,currentIndex:2,isClear:this.isClear}).zIndex(2)
Refresh({ refreshing: $$this.isRefreshing,builder:this.refreshComponent}) {
Scroll(){
Stack({alignContent:Alignment.Center}) {
if (this.currentIndex === 0){
novelPage({searchValue:this.searchValue,currentIndex:0,isClear:this.isClear,EXHIBIT:this.EXHIBIT,isShowCheck:this.isShowCheck}).zIndex(0)
} else if(this.currentIndex === 1) {
cartoonPage({searchValue:this.searchValue,currentIndex:1,isClear:this.isClear,EXHIBIT:this.EXHIBIT,isShowCheck:this.isShowCheck}).zIndex(1)
} else if(this.currentIndex === 2) {
soundPage({searchValue:this.searchValue,currentIndex:2,isClear:this.isClear,EXHIBIT:this.EXHIBIT,isShowCheck:this.isShowCheck}).zIndex(2)
}
}
.padding({left:10,right:10})
}
.padding({left:10,right:10})
}
.align(Alignment.TopStart)
.height(this.searchValue==='浏览历史'?'83%':'78%')
.scrollBar(BarState.Off)
.align(Alignment.TopStart)
.height(this.searchValue==='浏览历史'?'83%':'78%')
.scrollBar(BarState.Off)
}.onStateChange((refreshStatus: RefreshStatus) =>{
if (refreshStatus === 1 || refreshStatus === 2) {
this.RefreshingTitle = '松开刷新'
} else{
this.RefreshingTitle = '刷新中...'
}
})
.onRefreshing(()=>{
setTimeout(() => {
this.counter++
this.isRefreshing = false
}, 1000)

})
}
}

@Builder ExhibitBuilder() {
Row({space:10}){
ForEach(this.EXHIBIT_NAMES, (item:string) => {
if (item !== this.EXHIBIT) {
IndexSearchType({ title: item, searchValue: this.searchValue })
.onClick(() => {
this.EXHIBIT = item
})
Divider()
.vertical(true)
.height(15)
.color('#989797')
.opacity(0.5)
.strokeWidth(1)
}
})
}
}

@Builder GroupBuilder() {
Row({space:10}){
ForEach(this.GROUP_NAMES, (item:string) => {
if (item !== this.GROUP) {
IndexSearchType({ title: item, searchValue: this.searchValue })
.onClick(() => {
this.GROUP = item
})
Divider()
.vertical(true)
.height(15)
.color('#989797')
.opacity(0.5)
.strokeWidth(1)
}
})
}
}

Expand All @@ -244,6 +302,18 @@ export default struct IndexShelf {
}.width('100%')
}

@Builder
refreshComponent()
{
Row()
{
if (this.RefreshingTitle !== '松开刷新'){
LoadingProgress().height(30)
}
Text(this.RefreshingTitle).fontSize(16).margin({left:20})
}
}

changeTheme(themeNum: number) {

}
Expand Down
157 changes: 157 additions & 0 deletions entry/src/main/ets/pages/view/bookShelf/BookInfoGrid.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import delDialogExample from '../../../componets/common/delDialog'
import router from '@ohos.router'
import { promptAction } from '@kit.ArkUI'

@Component
/**
* 书签_宫格
*/
export default struct BookInfoGrid{
//标题
@Prop title:string
//描述
@Prop describe:string
//章节
@Prop chapter:string
//图片
@Prop bookImage:Resource

@Prop searchValue:string

@Prop isJoin:boolean

@Prop isShowCheck:boolean

onDelete: () => void = () => {

}

//弹窗
bookInfoDel: CustomDialogController | null = new CustomDialogController({
builder: delDialogExample({
cancel: ()=> { this.onCancel() },
confirm: ()=> { this.onAccept() }
}),
cancel: this.exitApp,
autoCancel: true,
alignment: DialogAlignment.Center,
// offset: { dx: 0, dy: '-40%' },
gridCount: 4,
customStyle: false,
cornerRadius: 25,
})

onCancel() {
console.info('取消')
}

onAccept() {
this.onDelete()
}

exitApp() {
console.info('点外围取消')
}


build() {
Column() {
Column(){
if (this.isShowCheck){
Flex({
alignItems: ItemAlign.End,
justifyContent:FlexAlign.End
}){
Checkbox({
name: this.title
})
.unselectedColor('rgba(255, 255, 255, 0.6)')
}
.borderRadius(10)
.backgroundColor(this.isShowCheck ?'rgba(0, 0, 0, 0.3)':'')
.width(90).height(120)
}
if (this.searchValue === '浏览历史'){
Flex({
justifyContent:FlexAlign.SpaceBetween,
alignItems: ItemAlign.End
}){
Row(){
Row({space:5}){
Image(this.isJoin?$r("app.media.add_check"):$r("app.media.add_shelf")).width(10).height(10)
.fillColor('rgb(255, 255, 255)')
Text('书架').fontSize(8).fontColor('rgb(255, 255, 255)')
}.padding({ left:8,right:8,bottom:5,top:5 })
}
.margin({bottom:3})
.backgroundColor(this.isJoin?'rgba(255, 255, 255,0.5)':'')
.borderColor('rgb(255, 255, 255)')
.borderWidth(this.isJoin?0:1)
.borderRadius(50)
.onClick(()=>{
this.isJoin = !this.isJoin
promptAction.showToast({
message: this.isJoin?'已加入书架':'已移出书架',
duration: 1000,
})
})

Image($r('app.media.delete_svg')).width(17).fillColor('rgb(255, 255, 255)')
.margin({bottom:3})
.onClick(()=>{
if (this.bookInfoDel != null) {
this.bookInfoDel.open()
}
})
}
.padding({left:5,right:5})
.borderRadius(10)
.backgroundColor(this.searchValue === '浏览历史'?'rgba(0, 0, 0, 0.3)':'')
.width(90).height(120)
}
}
.borderRadius(10)
.width(90).height(120)
.backgroundImage(this.bookImage)
.backgroundImageSize({width:90,height:120})

Text(this.title)
.fontSize(15)
.fontWeight(700)
.textOverflow({
overflow:TextOverflow.Ellipsis
})
.ellipsisMode(EllipsisMode.END)
.maxLines(2)
//描述
// Text(this.describe).fontSize(12).fontColor('rgb(174,174,174)')
// .textOverflow({
// overflow:TextOverflow.Ellipsis
// })
// .ellipsisMode(EllipsisMode.END)
// .fontWeight(500)
// .maxLines(1)
Text(this.chapter).fontSize(12).fontColor('rgb(174,174,174)')
.textOverflow({
overflow:TextOverflow.Ellipsis
})
.ellipsisMode(EllipsisMode.END)
.fontWeight(500)
.maxLines(1)
}
.padding({ left:8,right:8,bottom:5,top:5 })
.backgroundColor('rgba(244,244,244,0.8)')
.onClick(()=>{
router.pushUrl({
url: 'pages/view/BookDetailPage',
params: {
bookId: '1',
bookName: '大奉打更人',
bookAuthor: '卖报小郎君',
bookImage: $r('app.media.cover_list'),
bookDescribe: '《大奉打更人》(第一卷)实体书已在天猫、当当、京东等全平台,以及各个实体书店发售。 这个世界,有儒;有道;有佛;有妖;有术士。 警校毕业的许七安幽幽醒来,发现自己身处牢狱之中,三日后流放边陲..... '
}
})
})
}
}
Loading

0 comments on commit ea969f2

Please sign in to comment.