jwautumn / acarousel Goto Github PK
View Code? Open in Web Editor NEWA carousel view for SwiftUI | SwiftUI 旋转木马效果
License: MIT License
A carousel view for SwiftUI | SwiftUI 旋转木马效果
License: MIT License
View text becomes stretched when scrolling and if I set the test with font size then top view text ok but scroll view text looks stretched
I've been playing around trying to figure out how I could get a full image (image 1) and half of the next image (image 2) to show before scrolling completely over to see image 2? Hope that made sense?
The autoScrolling feature in your code using .defaultActive should rotate from A, B, C, A, B C without jumping back to A from C. It should just be continous.
I added a Navigation link on the item in order to push a new view but by adding the navigation link (or a button) the swiping don't work anymore.
Any solution to have the item swipe and the navigation link on the item?
參考你的程式中 發現到您撰寫了 ACarousel_LibraryContent
想請教這個的用途是??
GeometryReader包裹ACarousel时会产生一条空白区域(如图所示),但是包裹Image不会产生横线,请问如何去掉该空白区域。代码分别如下所示。
/// GeometryReader下为Image时,效果正常,无空白区域
struct StickyDetailImageView: View {
var body: some View {
ScrollView(.vertical, showsIndicators: false) {
GeometryReader { geometry in
Image("ic_img_placeholder")
.resizable()
.scaledToFill()
.clipped()
.frame(width: geometry.size.width, height: 250)
}
.frame(height: 250)
.background(.blue)
Text("GeometryReader下为Image时,效果正常,无空白区域").frame(width: UIScreen.main.bounds.width, height: 300).background(.green)
}
.ignoresSafeArea()
}
}
/// GeometryReader下为ACarousel时,效果异常,GeometryReader下会产生一条空白区域
struct StickyDetailACarouselView: View {
let lstBannerData: [DataResBean] = [DataResBean(id: 1, url: "ic_img_placeholder"), DataResBean(id: 2, url: "AppIcon"), DataResBean(id: 3, url: "ic_qrcode_app_download")]
@State var currentBannerIndex = 0
var body: some View {
ScrollView(.vertical, showsIndicators: false) {
GeometryReader { geometry in
ACarousel(lstBannerData,
index: $currentBannerIndex,
spacing: 0,
headspace: 0,
sidesScaling: 1.0,
isWrap: true,
autoScroll: .inactive) { item in
Image(item.url)
.resizable()
.scaledToFill()
.frame(width: geometry.size.width, height: .none)
}
.frame(width: geometry.size.width, height: 250)
.background(.red)
.onTapGesture {
print(geometry.frame(in: .global).minY)
}
}
.frame(height: 250)
.background(.blue)
Text("GeometryReader下为ACarousel时,效果异常,GeometryReader下会产生一条空白区域").frame(width: UIScreen.main.bounds.width, height: 300).background(.green)
}
.ignoresSafeArea()
}
Example:
...Other code
@State var currIndex: Int = 0
var body: some View {
ACarousel(items, id: \.id, index: $currIndex, ...) { ... }
}
In this case, the animations will not occur properly. Demo:
https://drive.google.com/file/d/1asAYFM6B3ZREpgqhD4Kr3behYqe2bsy9/view?usp=sharing
@JWAutumn @underthestars-zhy @krin-san @thitran-incepit @TheAuttom We need your attention on this package, please. We need you guys to merge pull request, respond to issues.
Cool view. Thanks for sharing!
I would like to use ACarousel to select an item, but the button is not an item view, it is a fixed button.
So running a closure when the primary item is moved would be helpful.
Is there a way to make the transition to the next slide faster?
Is there a way or
Could you add the repository in cocoapods?
thank you!
add a nice indicator
@TheAuttom
@JWAutumn
It's an awesome library for this feature, First in SwiftUI I think.
However there is an improvement that will make it more useful.
There is no way to access the information what object is currently in Focus.
a) In case of Auto Scrolling turned ON
b) In case of Auto Scrolling turned OFF and user is manually dragging etc.
There is an AState Observable Object but it is set to private. Can you please provide a way to get that information?
Hi, I want to recognize which item is in center how can I do that?
because my item content is too long, so I need to add the scrollview in the top level of my content view, like that:
ACarousel(pages) { page in
ScrollView(.vertical) {
VStack{...}
}
}
but if you scroll a little right-down, it will show around 10-20px padding in right side. I already set the space & headSpace to 0
also does not work.
how to fix it?
thanks
This is the sample structure:
TabView {
VStack {
ACarousel(items) { item in
ItemView(item)
.onTapGesture { "do something" }
}
}
VStack {...}
VStack {...}
VStack {...}
}
.tabViewStyle(.page(indexDisplayMode: .never))
I want to swipe the carousel item if i drag inside
anyone else feels this way? is there any way to make it feel easier?
我使用以下 Code:
ACarousel(urls, id: \.self, index: $bannerIndex, spacing: 10, headspace: 10, sidesScaling: 0.8, isWrap: true, autoScroll: .active(3)) { url in BannerNetworkImage(urlString: url) .frame(height: 150) .cornerRadius(10) } .frame(height: 150)
但是滑動範圍超過了高度 150,可否修正呢?
因為這樣的話造成使用者不小心滑動到 (手沒在圖片上 依然可以滑動,似乎是全畫面手勢??)
例如我設置 150
但是在圖片的下緣 約高度 160 還是可滑動 .... !?
以上您的範例也可以重現
i’m having a crash in this library and i can’t seem to pinpoint it.
i have dynamic data so it can also have zero items.
in this case what seems to be the only working thing is to set the index to -1, but i’m not sure if it’s the right way.
any suggestions on how to add Right-to-left support for Localization.
i’m having a crash in this library and i can’t seem to pinpoint it.
i have dynamic data so it can also have zero items.
in this case what seems to be the only working thing is to set the index to -1, but i’m not sure if it’s the right way.
#7 0x0000000100861948 in closure #1 in closure #1 in ACarousel.generateContent(proxy:) ()
this is what i can get.
import SwiftUI
import ACarousel
struct testModel: Identifiable {
let id: UUID = UUID()
let title: String
}
struct PlanListBannerView: View {
let items: [testModel] = [testModel(title: "123"), testModel(title: "234"), testModel(title: "345")]
@State var index: Int = 0
var body: some View {
ACarousel(items,
index: $index,
spacing: 16,
headspace: 10,
sidesScaling: 0.8,
isWrap: true,
autoScroll: .active(5)) { item in
Text(item.title)
}.frame(height: 160)
.border(.black, width: 1)
}
}
struct PlanListBannerView_Previews: PreviewProvider {
static var previews: some View {
PlanListBannerView()
}
}
run this code on iPhone 11, Xcode 13.2.1
it will appear something like this, how fix it?
ForEach<Array, UUID, ModifiedContent<ModifiedContent<Text, _FrameLayout>, _ScaleEffect>>: the ID 39C04D53-1D36-4AA6-B765-2A34FFB78DE7 occurs multiple times within the collection, this will give undefined results!
ForEach<Array, UUID, ModifiedContent<ModifiedContent<Text, _FrameLayout>, _ScaleEffect>>: the ID E36F64ED-93BF-46B5-ADAB-9B087D8F7CC3 occurs multiple times within the collection, this will give undefined results!
0.0
ForEach<Array, UUID, ModifiedContent<ModifiedContent<Text, _FrameLayout>, _ScaleEffect>>: the ID C6E86B38-1956-473C-AF9F-96A81F878561 occurs multiple times within the collection, this will give undefined results!
ForEach<Array, UUID, ModifiedContent<ModifiedContent<Text, _FrameLayout>, _ScaleEffect>>: the ID E2817A77-5311-4F80-8AEF-5816AB86C0EC occurs multiple times within the collection, this will give undefined results!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.