commit 12febf96712acf2093276441a1fdcaa293ae1ea9
parent 4033ad66baaf72db37196c195316666a2730c743
Author: William Casarin <jb55@jb55.com>
Date: Mon, 17 Jul 2023 13:25:17 -0700
view: extract ProfileEditButton to its own file
profile view file is getting cray cray
Diffstat:
3 files changed, 55 insertions(+), 32 deletions(-)
diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj
@@ -189,6 +189,7 @@
4C987B57283FD07F0042CE38 /* FollowersModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C987B56283FD07F0042CE38 /* FollowersModel.swift */; };
4C9AA14A2A4587A6003F49FD /* NotificationStatusModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9AA1492A4587A6003F49FD /* NotificationStatusModel.swift */; };
4C9B0DEE2A65A75F00CBDA21 /* AttrStringTestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9B0DED2A65A75F00CBDA21 /* AttrStringTestExtensions.swift */; };
+ 4C9B0DF32A65C46800CBDA21 /* ProfileEditButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9B0DF22A65C46800CBDA21 /* ProfileEditButton.swift */; };
4C9BB83129C0ED4F00FC4E37 /* DisplayName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9BB83029C0ED4F00FC4E37 /* DisplayName.swift */; };
4C9BB83429C12D9900FC4E37 /* EventProfileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9BB83329C12D9900FC4E37 /* EventProfileName.swift */; };
4C9F18E229AA9B6C008C55EC /* CustomizeZapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9F18E129AA9B6C008C55EC /* CustomizeZapView.swift */; };
@@ -666,6 +667,7 @@
4C987B56283FD07F0042CE38 /* FollowersModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowersModel.swift; sourceTree = "<group>"; };
4C9AA1492A4587A6003F49FD /* NotificationStatusModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationStatusModel.swift; sourceTree = "<group>"; };
4C9B0DED2A65A75F00CBDA21 /* AttrStringTestExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttrStringTestExtensions.swift; sourceTree = "<group>"; };
+ 4C9B0DF22A65C46800CBDA21 /* ProfileEditButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileEditButton.swift; sourceTree = "<group>"; };
4C9BB83029C0ED4F00FC4E37 /* DisplayName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayName.swift; sourceTree = "<group>"; };
4C9BB83329C12D9900FC4E37 /* EventProfileName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventProfileName.swift; sourceTree = "<group>"; };
4C9F18E129AA9B6C008C55EC /* CustomizeZapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeZapView.swift; sourceTree = "<group>"; };
@@ -1376,6 +1378,7 @@
4C9BB83329C12D9900FC4E37 /* EventProfileName.swift */,
4C8D1A6B29F1DFC200ACDF75 /* FriendIcon.swift */,
3A4647CE2A413ADC00386AD8 /* CondensedProfilePicturesView.swift */,
+ 4C9B0DF22A65C46800CBDA21 /* ProfileEditButton.swift */,
);
path = Profile;
sourceTree = "<group>";
@@ -2128,6 +2131,7 @@
4C9AA14A2A4587A6003F49FD /* NotificationStatusModel.swift in Sources */,
4CB9D4A72992D02B00A9A7E4 /* ProfileNameView.swift in Sources */,
4CE4F0F429D779B5005914DB /* PostBox.swift in Sources */,
+ 4C9B0DF32A65C46800CBDA21 /* ProfileEditButton.swift in Sources */,
4C2859622A12A7F0004746F7 /* GoldSupportGradient.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/damus/Views/Profile/ProfileEditButton.swift b/damus/Views/Profile/ProfileEditButton.swift
@@ -0,0 +1,50 @@
+//
+// ProfileEditButton.swift
+// damus
+//
+// Created by William Casarin on 2023-07-17.
+//
+
+import SwiftUI
+
+struct ProfileEditButton: View {
+ let damus_state: DamusState
+
+ @Environment(\.colorScheme) var colorScheme
+
+ var body: some View {
+ NavigationLink(value: Route.EditMetadata) {
+ Text("Edit", comment: "Button to edit user's profile.")
+ .frame(height: 30)
+ .padding(.horizontal,25)
+ .font(.caption.weight(.bold))
+ .foregroundColor(fillColor())
+ .cornerRadius(24)
+ .overlay {
+ RoundedRectangle(cornerRadius: 24)
+ .stroke(borderColor(), lineWidth: 1)
+ }
+ .minimumScaleFactor(0.5)
+ .lineLimit(1)
+ }
+ }
+
+ func fillColor() -> Color {
+ colorScheme == .light ? DamusColors.black : DamusColors.white
+ }
+
+ func borderColor() -> Color {
+ colorScheme == .light ? DamusColors.black : DamusColors.white
+ }
+}
+
+
+struct ProfileEditButton_Previews: PreviewProvider {
+ static var previews: some View {
+ Group {
+ ProfileEditButton(damus_state: test_damus_state())
+ }
+ }
+}
+
+
diff --git a/damus/Views/Profile/ProfileView.swift b/damus/Views/Profile/ProfileView.swift
@@ -56,37 +56,6 @@ func followedByString(_ friend_intersection: [String], profiles: Profiles, local
}
}
-struct EditButton: View {
- let damus_state: DamusState
-
- @Environment(\.colorScheme) var colorScheme
-
- var body: some View {
- NavigationLink(value: Route.EditMetadata) {
- Text("Edit", comment: "Button to edit user's profile.")
- .frame(height: 30)
- .padding(.horizontal,25)
- .font(.caption.weight(.bold))
- .foregroundColor(fillColor())
- .cornerRadius(24)
- .overlay {
- RoundedRectangle(cornerRadius: 24)
- .stroke(borderColor(), lineWidth: 1)
- }
- .minimumScaleFactor(0.5)
- .lineLimit(1)
- }
- }
-
- func fillColor() -> Color {
- colorScheme == .light ? DamusColors.black : DamusColors.white
- }
-
- func borderColor() -> Color {
- colorScheme == .light ? DamusColors.black : DamusColors.white
- }
-}
-
struct VisualEffectView: UIViewRepresentable {
var effect: UIVisualEffect?
@@ -308,7 +277,7 @@ struct ProfileView: View {
)
} else if damus_state.keypair.privkey != nil {
NavigationLink(value: Route.EditMetadata) {
- EditButton(damus_state: damus_state)
+ ProfileEditButton(damus_state: damus_state)
}
}