Skip to content

Commit

Permalink
Merge pull request #3 from tichise/feature/icon
Browse files Browse the repository at this point in the history
Add the icon color setting function.
  • Loading branch information
tichise authored Sep 19, 2020
2 parents 8c03fff + 605eb71 commit bb423bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion OMJoystick.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'OMJoystick'
s.version = '0.5.4'
s.version = '0.6.0'
s.swift_versions = '5.0'
s.license = 'MIT'
s.summary = 'This is the Joystick UI library for SwiftUI.'
Expand Down
4 changes: 3 additions & 1 deletion Sample/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1160;
LastUpgradeCheck = 1160;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = tichise;
TargetAttributes = {
B021BC402504B56E00BFB99E = {
Expand Down Expand Up @@ -350,6 +350,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -410,6 +411,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
4 changes: 2 additions & 2 deletions Sample/Sample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ContentView: View {
downIcon: Image(systemSymbol: .arrowDown)
)

let colorSetting = ColorSetting(subRingColor: .red, bigRingNormalBackgroundColor: .green, bigRingDarkBackgroundColor: .blue, bigRingStrokeColor: .yellow)
let colorSetting = ColorSetting(subRingColor: .red, bigRingNormalBackgroundColor: .green, bigRingDarkBackgroundColor: .blue, bigRingStrokeColor: .yellow, iconColor: .red)

var body: some View {
GeometryReader { geometry in
Expand All @@ -32,7 +32,7 @@ struct ContentView: View {

}.frame(width: geometry.size.width-40, height: geometry.size.width-40)

OMJoystick(isDebug: true, iconSetting: self.iconSetting, colorSetting: ColorSetting(), smallRingRadius: 70, bigRingRadius: 120
OMJoystick(isDebug: true, iconSetting: self.iconSetting, colorSetting: ColorSetting(iconColor: .orange), smallRingRadius: 70, bigRingRadius: 120
) { (joyStickState, stickPosition) in
TILogger().info(joyStickState.rawValue)
TILogger().info(stickPosition)
Expand Down
15 changes: 10 additions & 5 deletions Sources/OMJoyStick.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,25 @@ public struct ColorSetting {
var bigRingNormalBackgroundColor: Color
var bigRingDarkBackgroundColor: Color
var bigRingStrokeColor: Color
var iconColor: Color

public init(subRingColor: Color = .primary,
bigRingNormalBackgroundColor: Color = .white,
bigRingDarkBackgroundColor: Color = .black,
bigRingStrokeColor: Color = Color.primary) {
bigRingStrokeColor: Color = Color.primary,
iconColor: Color = Color.primary) {

self.subRingColor = subRingColor
self.bigRingNormalBackgroundColor = bigRingNormalBackgroundColor
self.bigRingDarkBackgroundColor = bigRingDarkBackgroundColor
self.bigRingStrokeColor = bigRingStrokeColor
self.iconColor = iconColor
}
}

public struct OMJoystick: View {

var iconColor: Color
var subRingColor: Color
var bigRingNormalBackgroundColor: Color
var bigRingDarkBackgroundColor: Color
Expand Down Expand Up @@ -200,6 +204,7 @@ public struct OMJoystick: View {

self.isDebug = isDebug

self.iconColor = colorSetting.iconColor
self.subRingColor = colorSetting.subRingColor
self.bigRingNormalBackgroundColor = colorSetting.bigRingNormalBackgroundColor
self.bigRingDarkBackgroundColor = colorSetting.bigRingDarkBackgroundColor
Expand Down Expand Up @@ -234,11 +239,11 @@ public struct OMJoystick: View {
}

upIcon?.renderingMode(.template)
.foregroundColor(.secondary).padding(iconPadding)
.foregroundColor(iconColor).padding(iconPadding)

HStack() {
leftIcon?.renderingMode(.template)
.foregroundColor(.secondary).padding(iconPadding)
.foregroundColor(iconColor).padding(iconPadding)

ZStack {
// 中央は直径280の場合は140:140
Expand All @@ -251,11 +256,11 @@ public struct OMJoystick: View {
}

rightIcon?.renderingMode(.template)
.foregroundColor(.secondary).padding(iconPadding)
.foregroundColor(iconColor).padding(iconPadding)
}

downIcon?.renderingMode(.template)
.foregroundColor(.secondary).padding(iconPadding)
.foregroundColor(iconColor).padding(iconPadding)

if isDebug {
HStack(spacing: 15) {
Expand Down

0 comments on commit bb423bb

Please sign in to comment.