Skip to content

Commit f9eee4e

Browse files
committed
Add AAButtonTheme for AAResetButton
1 parent 949a962 commit f9eee4e

File tree

4 files changed

+216
-15
lines changed

4 files changed

+216
-15
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
//
2+
// AAButtonTheme.swift
3+
// AAInfographics
4+
//
5+
// Created by AnAn on 2024/11/5.
6+
// Copyright © 2024 An An. All rights reserved.
7+
//
8+
9+
/**
10+
buttonTheme:{
11+
fill:#f7f7f7
12+
padding:8
13+
r:2
14+
states:{
15+
disabled:{
16+
style:{
17+
color:#cccccc
18+
}
19+
}
20+
hover:{
21+
fill:#e6e6e6
22+
}
23+
select:{
24+
fill:#e6e9ff
25+
style:{
26+
color:#000000
27+
fontWeight:bold
28+
}
29+
}
30+
}
31+
stroke:#cccccc
32+
stroke-width:1
33+
style:{
34+
color:#333333
35+
cursor:pointer
36+
fontSize:0.8em
37+
fontWeight:normal
38+
}
39+
}
40+
*/
41+
public class AAButtonThemeStatesDisabled: AAObject {
42+
public var style: AAStyle?
43+
44+
@discardableResult
45+
public func style(_ prop: AAStyle?) -> AAButtonThemeStatesDisabled {
46+
style = prop
47+
return self
48+
}
49+
50+
public override init() {
51+
52+
}
53+
}
54+
55+
public class AAButtonThemeStatesHover: AAObject {
56+
public var fill: String?
57+
public var style: AAStyle?
58+
59+
@discardableResult
60+
public func fill(_ prop: String?) -> AAButtonThemeStatesHover {
61+
fill = prop
62+
return self
63+
}
64+
65+
@discardableResult
66+
public func style(_ prop: AAStyle?) -> AAButtonThemeStatesHover {
67+
style = prop
68+
return self
69+
}
70+
71+
public override init() {
72+
73+
}
74+
}
75+
76+
public class AAButtonThemeStatesSelect: AAObject {
77+
public var fill: String?
78+
public var style: AAStyle?
79+
80+
@discardableResult
81+
public func fill(_ prop: String?) -> AAButtonThemeStatesSelect {
82+
fill = prop
83+
return self
84+
}
85+
86+
@discardableResult
87+
public func style(_ prop: AAStyle?) -> AAButtonThemeStatesSelect {
88+
style = prop
89+
return self
90+
}
91+
92+
public override init() {
93+
94+
}
95+
}
96+
97+
98+
99+
100+
101+
102+
103+
public class AAButtonThemeStates: AAObject {
104+
public var disabled: AAButtonThemeStatesDisabled?
105+
public var hover: AAButtonThemeStatesHover?
106+
public var select: AAButtonThemeStatesSelect?
107+
108+
@discardableResult
109+
public func disabled(_ prop: AAButtonThemeStatesDisabled?) -> AAButtonThemeStates {
110+
disabled = prop
111+
return self
112+
}
113+
114+
@discardableResult
115+
public func hover(_ prop: AAButtonThemeStatesHover?) -> AAButtonThemeStates {
116+
hover = prop
117+
return self
118+
}
119+
120+
@discardableResult
121+
public func select(_ prop: AAButtonThemeStatesSelect?) -> AAButtonThemeStates {
122+
select = prop
123+
return self
124+
}
125+
126+
public override init() {
127+
128+
}
129+
}
130+
131+
132+
//https://api.highcharts.com/highcharts/global.buttonTheme
133+
public class AAButtonTheme: AAObject {
134+
public var fill: String?
135+
public var padding: Float?
136+
public var r: Float?
137+
public var states: AAButtonThemeStates?
138+
public var stroke: String?
139+
public var strokeWidth: Float?
140+
public var style: AAStyle?
141+
142+
@discardableResult
143+
public func fill(_ prop: String?) -> AAButtonTheme {
144+
fill = prop
145+
return self
146+
}
147+
148+
@discardableResult
149+
public func padding(_ prop: Float?) -> AAButtonTheme {
150+
padding = prop
151+
return self
152+
}
153+
154+
@discardableResult
155+
public func r(_ prop: Float?) -> AAButtonTheme {
156+
r = prop
157+
return self
158+
}
159+
160+
@discardableResult
161+
public func states(_ prop: AAButtonThemeStates?) -> AAButtonTheme {
162+
states = prop
163+
return self
164+
}
165+
166+
@discardableResult
167+
public func stroke(_ prop: String?) -> AAButtonTheme {
168+
stroke = prop
169+
return self
170+
}
171+
172+
@discardableResult
173+
public func strokeWidth(_ prop: Float?) -> AAButtonTheme {
174+
strokeWidth = prop
175+
return self
176+
}
177+
178+
@discardableResult
179+
public func style(_ prop: AAStyle?) -> AAButtonTheme {
180+
style = prop
181+
return self
182+
}
183+
184+
public override init() {
185+
186+
}
187+
}

AAInfographics/AAOptionsModel/AAChart.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public class AAMouseWheel: AAObject {
449449
public class AAResetButton: AAObject {
450450
public var position: AAPosition?
451451
public var relativeTo: String?
452-
public var theme: [String: Any]?
452+
public var theme: AAButtonTheme?
453453

454454
@discardableResult
455455
public func position(_ prop: AAPosition?) -> AAResetButton {
@@ -464,7 +464,7 @@ public class AAResetButton: AAObject {
464464
}
465465

466466
@discardableResult
467-
public func theme(_ prop: [String: Any]?) -> AAResetButton {
467+
public func theme(_ prop: AAButtonTheme?) -> AAResetButton {
468468
theme = prop
469469
return self
470470
}

AAInfographicsDemo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
84086B1E28E6C612006BD30D /* CustomTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84086B1C28E6C612006BD30D /* CustomTableViewCell.swift */; };
5555
84086B1F28E6C612006BD30D /* CustomTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84086B1D28E6C612006BD30D /* CustomTableViewCell.xib */; };
5656
84086B2128E6F499006BD30D /* JSFunctionForAAOptionsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84086B2028E6F499006BD30D /* JSFunctionForAAOptionsVC.swift */; };
57+
8409E6BA2CDA3805000EFCF2 /* AAButtonTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8409E6B92CDA3805000EFCF2 /* AAButtonTheme.swift */; };
5758
840AC39A280CFFA200B10289 /* AAAxis.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840AC396280CFFA200B10289 /* AAAxis.swift */; };
5859
8418479928B8755900094106 /* JSFunctionForAAChartEventsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8418479828B8755900094106 /* JSFunctionForAAChartEventsVC.swift */; };
5960
842FC3EE2CBE119500FBAD3A /* CustomTooltipEventCallbackVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842FC3ED2CBE119500FBAD3A /* CustomTooltipEventCallbackVC.swift */; };
@@ -264,6 +265,7 @@
264265
84086B1C28E6C612006BD30D /* CustomTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTableViewCell.swift; sourceTree = "<group>"; };
265266
84086B1D28E6C612006BD30D /* CustomTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomTableViewCell.xib; sourceTree = "<group>"; };
266267
84086B2028E6F499006BD30D /* JSFunctionForAAOptionsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSFunctionForAAOptionsVC.swift; sourceTree = "<group>"; };
268+
8409E6B92CDA3805000EFCF2 /* AAButtonTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AAButtonTheme.swift; sourceTree = "<group>"; };
267269
840AC396280CFFA200B10289 /* AAAxis.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AAAxis.swift; sourceTree = "<group>"; };
268270
8418479828B8755900094106 /* JSFunctionForAAChartEventsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSFunctionForAAChartEventsVC.swift; sourceTree = "<group>"; };
269271
842FC3ED2CBE119500FBAD3A /* CustomTooltipEventCallbackVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTooltipEventCallbackVC.swift; sourceTree = "<group>"; };
@@ -514,6 +516,7 @@
514516
27065A5B24C1A7A400D872EB /* AACredits.swift */,
515517
27E58D3626EA18B900A0709E /* AAStyle.swift */,
516518
2DC11FD83D319267C3D1C1DE /* AABubbleLegend.swift */,
519+
8409E6B92CDA3805000EFCF2 /* AAButtonTheme.swift */,
517520
);
518521
path = AAOptionsModel;
519522
sourceTree = "<group>";
@@ -961,6 +964,7 @@
961964
ED0A034A272816ED000BF778 /* AASeries.swift in Sources */,
962965
ED0A033A272816ED000BF778 /* AATooltip.swift in Sources */,
963966
ED0A0345272816ED000BF778 /* AAStyle.swift in Sources */,
967+
8409E6BA2CDA3805000EFCF2 /* AAButtonTheme.swift in Sources */,
964968
ED0A0333272816E3000BF778 /* AASerializable.swift in Sources */,
965969
ED0A0335272816ED000BF778 /* AASubtitle.swift in Sources */,
966970
ED0A0348272816ED000BF778 /* AAPlotOptions.swift in Sources */,

AAInfographicsDemo/Demo/AdditionalContent2/AABaseChartVC.swift

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,29 @@ class AABaseChartVC: UIViewController {
245245

246246
aaOptions.chart?.zooming = AAZooming()
247247
.resetButton(AAResetButton()
248-
.theme([
249-
"fill": "yellow",
250-
"stroke": "green",
251-
"r": 3,
252-
"states": [
253-
"hover": [
254-
"fill": "#ff0000",
255-
"style": [
256-
"color": "white"
257-
]
258-
]
259-
]
260-
]))
248+
// .theme([
249+
// "fill": "yellow",
250+
// "stroke": "green",
251+
// "r": 3,
252+
// "states": [
253+
// "hover": [
254+
// "fill": "#ff0000",
255+
// "style": [
256+
// "color": "white"
257+
// ]
258+
// ]
259+
// ]
260+
// ]))
261+
.theme(AAButtonTheme()
262+
.fill(AAColor.yellow)
263+
.stroke(AAColor.green)
264+
// .strokeWidth(6)
265+
.r(3)
266+
.states(AAButtonThemeStates()
267+
.hover(AAButtonThemeStatesHover()
268+
.fill(AAColor.red)
269+
.style(AAStyle()
270+
.color(AAColor.white))))))
261271
.singleTouch(true)
262272
.type(.x)
263273
.pinchType(.x)

0 commit comments

Comments
 (0)