diff --git a/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/Contents.json new file mode 100644 index 0000000..240d3bf --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_follow_big_en.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/btn_follow_big_en.png b/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/btn_follow_big_en.png new file mode 100644 index 0000000..9cdd7e7 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_follow_big_en.imageset/btn_follow_big_en.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/Contents.json new file mode 100644 index 0000000..838481e --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_follow_big_ja.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/btn_follow_big_ja.png b/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/btn_follow_big_ja.png new file mode 100644 index 0000000..16eea68 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_follow_big_ja.imageset/btn_follow_big_ja.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/Contents.json new file mode 100644 index 0000000..89de463 --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_following_big_en.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/btn_following_big_en.png b/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/btn_following_big_en.png new file mode 100644 index 0000000..291dfa3 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_following_big_en.imageset/btn_following_big_en.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/Contents.json new file mode 100644 index 0000000..0351b20 --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_following_big_ja.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/btn_following_big_ja.png b/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/btn_following_big_ja.png new file mode 100644 index 0000000..d4f0220 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_following_big_ja.imageset/btn_following_big_ja.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/Contents.json new file mode 100644 index 0000000..ddbcd4f --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_following_no_alarm_big_en.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/btn_following_no_alarm_big_en.png b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/btn_following_no_alarm_big_en.png new file mode 100644 index 0000000..d27c4a0 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_en.imageset/btn_following_no_alarm_big_en.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/Contents.json new file mode 100644 index 0000000..5cc88f6 --- /dev/null +++ b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btn_following_no_alarm_big_ja.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/btn_following_no_alarm_big_ja.png b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/btn_following_no_alarm_big_ja.png new file mode 100644 index 0000000..7aa0187 Binary files /dev/null and b/SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big_ja.imageset/btn_following_no_alarm_big_ja.png differ diff --git a/SodaLive/Sources/Common/FollowButtonImageAsset.swift b/SodaLive/Sources/Common/FollowButtonImageAsset.swift new file mode 100644 index 0000000..4c643ba --- /dev/null +++ b/SodaLive/Sources/Common/FollowButtonImageAsset.swift @@ -0,0 +1,66 @@ +// +// FollowButtonImageAsset.swift +// SodaLive +// +// Created by Codex on 2025/03/15. +// + +import SwiftUI + +enum FollowButtonImageType { + case follow + case following + case followingNoAlarm +} + +struct FollowButtonImageAsset { + let type: FollowButtonImageType + + var imageName: String { + let languageCode = LanguageHeaderProvider.current + let suffix: String + switch languageCode { + case "ja": + suffix = "_ja" + case "en": + suffix = "_en" + default: + suffix = "" + } + + switch type { + case .follow: + return "btn_follow_big\(suffix)" + case .following: + return "btn_following_big\(suffix)" + case .followingNoAlarm: + return "btn_following_no_alarm_big\(suffix)" + } + } + + var size: CGSize? { + let languageCode = LanguageHeaderProvider.current + guard languageCode == "ja" || languageCode == "en" else { return nil } + switch type { + case .follow: + return CGSize(width: 80, height: 26.7) + case .following, .followingNoAlarm: + return CGSize(width: 100, height: 26.7) + } + } + + @ViewBuilder + func imageView(defaultSize: CGSize? = nil) -> some View { + if let size = size { + Image(imageName) + .resizable() + .frame(width: size.width, height: size.height) + } else if let defaultSize = defaultSize { + Image(imageName) + .resizable() + .frame(width: defaultSize.width, height: defaultSize.height) + } else { + Image(imageName) + } + } +} diff --git a/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift b/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift index 21a5111..c11bb35 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift @@ -36,12 +36,12 @@ struct ContentDetailCreatorProfileView: View { Spacer() if creator.creatorId != UserDefaults.int(forKey: .userId) { - Image(creator.isFollow ? - creator.isNotify ? - "btn_following_big" : - "btn_following_no_alarm_big" : - "btn_follow_big" + let asset = FollowButtonImageAsset( + type: creator.isFollow + ? (creator.isNotify ? .following : .followingNoAlarm) + : .follow ) + asset.imageView() .onTapGesture { if creator.isFollowing { showCreatorFollowNotifyDialog(creator.creatorId) diff --git a/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift b/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift index a60a0fa..e476737 100644 --- a/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift +++ b/SodaLive/Sources/Content/Series/Detail/SeriesDetailView.swift @@ -152,13 +152,12 @@ struct SeriesDetailView: View { Spacer() if seriesDetail.creator.creatorId != UserDefaults.int(forKey: .userId) { - Image( - viewModel.isFollow ? - viewModel.isNotify ? - "btn_following_big" : - "btn_following_no_alarm_big" : - "btn_follow_big" + let asset = FollowButtonImageAsset( + type: viewModel.isFollow + ? (viewModel.isNotify ? .following : .followingNoAlarm) + : .follow ) + asset.imageView() .onTapGesture { if viewModel.isFollow { creatorId = seriesDetail.creator.creatorId diff --git a/SodaLive/Sources/Explorer/Profile/FollowerList/FollowerListItemView.swift b/SodaLive/Sources/Explorer/Profile/FollowerList/FollowerListItemView.swift index 410639e..835c41e 100644 --- a/SodaLive/Sources/Explorer/Profile/FollowerList/FollowerListItemView.swift +++ b/SodaLive/Sources/Explorer/Profile/FollowerList/FollowerListItemView.swift @@ -41,12 +41,12 @@ struct FollowerListItemView: View { Spacer() if let isFollow = item.isFollow, let isNotify = item.isNotify { - Image(isFollow ? - isNotify ? - "btn_following_big" : - "btn_following_no_alarm_big" : - "btn_follow_big" + let asset = FollowButtonImageAsset( + type: isFollow + ? (isNotify ? .following : .followingNoAlarm) + : .follow ) + asset.imageView() .onTapGesture { isFollow ? showCreatorFollowNotifyDialog(item.userId) : diff --git a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift index 506ca27..52e39e7 100644 --- a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift +++ b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift @@ -47,13 +47,12 @@ struct UserProfileView: View { .foregroundColor(.white) if creatorProfile.creator.creatorId != UserDefaults.int(forKey: .userId) { - Image( - creatorProfile.creator.isFollow ? - creatorProfile.creator.isNotify ? "btn_following_big": "btn_following_no_alarm_big" - : "btn_follow_big" + let asset = FollowButtonImageAsset( + type: creatorProfile.creator.isFollow + ? (creatorProfile.creator.isNotify ? .following : .followingNoAlarm) + : .follow ) - .resizable() - .frame(width: 83.3, height: 26.7) + asset.imageView(defaultSize: CGSize(width: 83.3, height: 26.7)) .onTapGesture { if creatorProfile.creator.isFollow { isShowFollowNotifyDialog = true diff --git a/SodaLive/Sources/Follow/FollowCreatorItemView.swift b/SodaLive/Sources/Follow/FollowCreatorItemView.swift index 184e8dd..545106e 100644 --- a/SodaLive/Sources/Follow/FollowCreatorItemView.swift +++ b/SodaLive/Sources/Follow/FollowCreatorItemView.swift @@ -36,13 +36,12 @@ struct FollowCreatorItemView: View { Spacer() - Image( - creator.isFollow ? - creator.isNotify ? - "btn_following_big" : - "btn_following_no_alarm_big" : - "btn_follow_big" + let asset = FollowButtonImageAsset( + type: creator.isFollow + ? (creator.isNotify ? .following : .followingNoAlarm) + : .follow ) + asset.imageView() .onTapGesture { if creator.isFollow { showCreatorFollowNotifyDialog(creator.creatorId)