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
//需要添加依赖 | |
//implementation "com.google.accompanist:accompanist-pager:0.24.4-alpha" | |
//implementation "com.google.accompanist:accompanist-pager-indicators:0.24.4-alpha" | |
@OptIn(ExperimentalPagerApi::class) | |
@Composable | |
fun PagerWithTabRow() { | |
val tabs = listOf("首页", "图片", "国内", "国际", "数读", "军事", "航空", "传媒研究院", "政务", "公益", "媒体") | |
val pagerState = rememberPagerState() |
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
import androidx.compose.foundation.background | |
import androidx.compose.foundation.border | |
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.foundation.shape.RoundedCornerShape | |
import androidx.compose.foundation.text.BasicTextField | |
import androidx.compose.foundation.text.KeyboardOptions | |
import androidx.compose.material.* | |
import androidx.compose.material.icons.Icons | |
import androidx.compose.material.icons.filled.ArrowLeft |
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
struct TimelineDemo: View { | |
var body: some View { | |
ScrollView{ | |
VStack(spacing: 0){ | |
TimelineItemView(first: true) | |
ForEach(0..<10){_ in | |
TimelineItemView() | |
} | |
TimelineItemView(last: true) | |
} |
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
struct ScrollViewDemo: View { | |
//ScorllView滚动偏移量 | |
@State private var offset: CGFloat = 0 | |
//header 最大高度 | |
private let headerMaxHeight: CGFloat = 250 | |
//计算 header 的偏移量 | |
private var headerOffset: CGFloat { |
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
import SwiftUI | |
extension View { | |
func gradientForeground<GradientForeground>(_ gragient: GradientForeground) -> some View where GradientForeground : View{ | |
self.overlay(gragient) | |
.mask(self) | |
} | |
} | |
struct ContentView: View { |
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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
NavigationView { | |
ScrollView{ | |
VStack{ | |
ForEach(0..<10){_ in | |
TimelineItemView() |
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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
NavigationView { | |
ScrollView{ | |
VStack{ | |
ForEach(0..<10){_ in | |
TimelineItemView() | |
} |