Skip to content

Commit

Permalink
Add AxisSegmentedView library. Add an item, 234.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasudev committed Mar 27, 2022
1 parent 1531f40 commit 291b5aa
Show file tree
Hide file tree
Showing 9 changed files with 1,479 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
"version": null
}
},
{
"package": "AxisSegmentedView",
"repositoryURL": "https://github.com/jasudev/AxisSegmentedView.git",
"state": {
"branch": "main",
"revision": "5793f16dfa13cfeefb5a789977834eceb3b9d7a9",
"version": null
}
},
{
"package": "AxisSheet",
"repositoryURL": "https://github.com/jasudev/AxisSheet.git",
Expand Down
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let package = Package(
.package(url: "https://github.com/jasudev/AxisContribution.git", .branch("main")),
.package(url: "https://github.com/jasudev/AxisTooltip.git", .branch("main")),
.package(url: "https://github.com/jasudev/AxisTabView.git", .branch("main")),
.package(url: "https://github.com/jasudev/AxisSegmentedView.git", .branch("main")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -43,7 +44,8 @@ let package = Package(
"AxisRatingBar",
"AxisContribution",
"AxisTooltip",
"AxisTabView"]),
"AxisTabView",
"AxisSegmentedView"]),
.testTarget(
name: "FabulaItemsProviderTests",
dependencies: ["FabulaItemsProvider"]),
Expand Down
26 changes: 15 additions & 11 deletions Sources/FabulaItemsProvider/Items/P10_CircleTypography.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,28 @@ extension P10_CircleTypography {

var body: some View {
ZStack {
ForEach(1..<(texts.count + 1)) { index in
GeometryReader { proxy in
if index % 2 == 1 {
CircleText(isDynamic: true, sec: store.time * Double(index), text: texts[index - 1], gap: CGFloat(getFontSize(proxy) * CGFloat(index)))
.foregroundColor(Color.fabulaPrimary)
}else {
CircleText(isDynamic: false, sec: store.time * -Double(index), text: texts[index - 1], gap: CGFloat(getFontSize(proxy) * CGFloat(index)))
.foregroundColor(Color.fabulaSecondary)
}
}
.opacity((CGFloat(texts.count) - CGFloat(index - 1)) * 0.2)
ForEach(1..<(texts.count + 1), id: \.self) { index in
getContent(index)
.opacity((CGFloat(texts.count) - CGFloat(index - 1)) * 0.2)
}
}
}

private func getFontSize(_ proxy: GeometryProxy) -> CGFloat {
return proxy.minSize / 2 * 0.1
}

private func getContent(_ index: Int) -> some View {
GeometryReader { proxy in
if index % 2 == 1 {
CircleText(isDynamic: true, sec: store.time * Double(index), text: texts[index - 1], gap: CGFloat(getFontSize(proxy) * CGFloat(index)))
.foregroundColor(Color.fabulaPrimary)
}else {
CircleText(isDynamic: false, sec: store.time * -Double(index), text: texts[index - 1], gap: CGFloat(getFontSize(proxy) * CGFloat(index)))
.foregroundColor(Color.fabulaSecondary)
}
}
}
}

class TimeIntervalStore: ObservableObject {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FabulaItemsProvider/Items/P12_Timeface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ fileprivate
struct CircleDotView: View {
var body: some View {
GeometryReader { proxy in
ForEach(1..<getCount(proxy)) { tick in
ForEach(1..<getCount(proxy), id: \.self) { tick in
ZStack {
Color.clear
Circle()
Expand Down
4 changes: 2 additions & 2 deletions Sources/FabulaItemsProvider/Items/P176_TabSegmentedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension P176_TabSegmentedView {

private var topView: some View {
HStack(spacing: spacingSize.width) {
ForEach(items.indices) { index in
ForEach(items.indices, id: \.self) { index in
if !isScrollable && index != 0 {
Spacer()
}
Expand All @@ -107,7 +107,7 @@ extension P176_TabSegmentedView {
private var bottomView: some View {
#if os(iOS)
TabView(selection: $index) {
ForEach(items.indices) { index in
ForEach(items.indices, id: \.self) { index in
items[index].bottom
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/FabulaItemsProvider/Items/P1_Timer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ClockTickView: View {
var body: some View {
GeometryReader { proxy in
ZStack(alignment: .center) {
ForEach(0..<tickCount) { tick in
ForEach(0..<tickCount, id: \.self) { tick in
Circle()
.fill(tick % 5 == 0 ? Color.fabulaFore1 : Color.fabulaFore2)
.frame(width: tick % 5 == 0 ? 5 : 2, height: tick % 5 == 0 ? 5 : 2)
Expand Down
Loading

0 comments on commit 291b5aa

Please sign in to comment.