ModernSidebarIconView.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import SwiftUI
  2. struct ModernSidebarIconView: View {
  3. let kind: SidebarIconKind
  4. var size: CGFloat = AppTheme.iconContainerSize
  5. var body: some View {
  6. ZStack {
  7. RoundedRectangle(cornerRadius: 8, style: .continuous)
  8. .fill(
  9. LinearGradient(
  10. colors: [
  11. kind.gradient[0].opacity(0.22),
  12. kind.gradient[1].opacity(0.08),
  13. ],
  14. startPoint: .topLeading,
  15. endPoint: .bottomTrailing
  16. )
  17. )
  18. RoundedRectangle(cornerRadius: 8, style: .continuous)
  19. .fill(
  20. LinearGradient(
  21. colors: [.white.opacity(0.14), .clear],
  22. startPoint: .top,
  23. endPoint: .center
  24. )
  25. )
  26. Image(systemName: kind.systemImage)
  27. .font(.system(size: size * 0.4, weight: .semibold))
  28. .foregroundStyle(
  29. LinearGradient(
  30. colors: kind.gradient,
  31. startPoint: .topLeading,
  32. endPoint: .bottomTrailing
  33. )
  34. )
  35. .shadow(color: kind.glowColor.opacity(0.35), radius: 3, y: 1)
  36. }
  37. .frame(width: size, height: size)
  38. .compositingGroup()
  39. .overlay {
  40. RoundedRectangle(cornerRadius: 8, style: .continuous)
  41. .stroke(
  42. LinearGradient(
  43. colors: [
  44. kind.gradient[0].opacity(0.45),
  45. kind.gradient[1].opacity(0.15),
  46. .white.opacity(0.06),
  47. ],
  48. startPoint: .topLeading,
  49. endPoint: .bottomTrailing
  50. ),
  51. lineWidth: 1
  52. )
  53. }
  54. .shadow(color: kind.glowColor.opacity(0.15), radius: 4, y: 1)
  55. }
  56. }
  57. struct ModernRedditIconView: View {
  58. var size: CGFloat = AppTheme.iconContainerSize
  59. private let gradient: [Color] = [
  60. Color(hex: 0xFF8C42),
  61. Color(hex: 0xFF4500),
  62. ]
  63. var body: some View {
  64. ZStack {
  65. RoundedRectangle(cornerRadius: 8, style: .continuous)
  66. .fill(
  67. LinearGradient(
  68. colors: [
  69. gradient[0].opacity(0.22),
  70. gradient[1].opacity(0.08),
  71. ],
  72. startPoint: .topLeading,
  73. endPoint: .bottomTrailing
  74. )
  75. )
  76. RoundedRectangle(cornerRadius: 8, style: .continuous)
  77. .fill(
  78. LinearGradient(
  79. colors: [.white.opacity(0.14), .clear],
  80. startPoint: .top,
  81. endPoint: .center
  82. )
  83. )
  84. RedditLogoView(size: size * 0.5)
  85. }
  86. .frame(width: size, height: size)
  87. .compositingGroup()
  88. .overlay {
  89. RoundedRectangle(cornerRadius: 8, style: .continuous)
  90. .stroke(
  91. LinearGradient(
  92. colors: [
  93. gradient[0].opacity(0.5),
  94. gradient[1].opacity(0.2),
  95. .white.opacity(0.06),
  96. ],
  97. startPoint: .topLeading,
  98. endPoint: .bottomTrailing
  99. ),
  100. lineWidth: 1
  101. )
  102. }
  103. .shadow(color: gradient[1].opacity(0.18), radius: 4, y: 1)
  104. }
  105. }