Skip to content

Commit

Permalink
feat: 添加一下功能
Browse files Browse the repository at this point in the history
1: 消息通知的UI
2: 添加播放量和是否播放的overlay
  • Loading branch information
Until-You-Possible committed Aug 6, 2023
1 parent 905d673 commit ef5c1b2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ struct ExploreView: View {
Button {
print("show the left menu")
} label: {
FontIcon.text(.materialIcon(code: .menu), fontsize: 26)
ZStack {
FontIcon.text(.materialIcon(code: .menu), fontsize: 26)
// Replace "xxx" with the actual badge value you want to display
Text("20")
.font(.system(size: 8))
.foregroundColor(.white)
.padding(5)
.background(Color.red)
.clipShape(Circle())
.offset(x: 10, y: -6) // Adjust the offset to position the badge as per your requirement
}

}
.buttonStyle(PlainButtonStyle())
.foregroundColor(.black)
.badge(10)

// MARK: search wrapper
Button(action: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,45 @@ struct EntrySlideView: View {
@ObservedObject var entrySildeViewModel = EntrySlideViewModel()

var body: some View {
Text("view")

if let entryList = entrySildeViewModel.entryArray {
TabView(selection: $currentPage) {
ForEach(entryList.indices, id: \.self) { index in
let current = entryList[index]
HStack {
ForEach(0..<current.count, id: \.self) { innerIndex in
let innerCurrent = current[innerIndex]
VStack {
Text(innerCurrent["name"].stringValue)
}
}
}
}
}
.frame(width: .infinity, height: 80)
.tabViewStyle(.page(indexDisplayMode: .never))
.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
.onReceive(timer) { _ in
let newIndex = (currentPage + 1) % 2
withAnimation {
currentPage = newIndex
}
}
.gesture(
DragGesture()
.onChanged { _ in
// 用户手动滑动时暂停自动轮播
isAutoScrolling = false
}
.onEnded { _ in
// 用户停止滑动后继续自动轮播
isAutoScrolling = true
}
)
} else {
ProgressView()
}
// if let entryList = entrySildeViewModel.entryArray {
// TabView(selection: $currentPage) {
// ForEach(entryList.indices, id: \.self) { index in
// let current = entryList[index]
// HStack {
// ForEach(0..<current.count, id: \.self) { innerIndex in
// let innerCurrent = current[innerIndex]
// VStack {
// Text(innerCurrent["name"].stringValue)
// }
// }
// }
// }
// }
// .frame(width: .infinity, height: 80)
// .tabViewStyle(.page(indexDisplayMode: .never))
// .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
// .onReceive(timer) { _ in
// let newIndex = (currentPage + 1) % 2
// withAnimation {
// currentPage = newIndex
// }
// }
// .gesture(
// DragGesture()
// .onChanged { _ in
// // 用户手动滑动时暂停自动轮播
// isAutoScrolling = false
// }
// .onEnded { _ in
// // 用户停止滑动后继续自动轮播
// isAutoScrolling = true
// }
// )
// } else {
// ProgressView()
// }


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ struct RecommendationView: View {
.frame(width: 140, height: 140)
.cornerRadius(10)
}
.overlay (
FontIcon.text(.materialIcon(code: .play_circle_filled),
fontsize: 26, color: Color.gray)
.offset(x: -10, y: -10),
alignment: .bottomTrailing
)
.overlay (
HStack {
Text("456万")
.foregroundColor(Color.white)
.font(.system(size: 12))
.offset(
x: -10,
y: 10
)
},
alignment: .topTrailing
)

Text(current.infoText)
.font(.system(size: 12))
.lineLimit(2)
Expand Down

0 comments on commit ef5c1b2

Please sign in to comment.