@@ -41,10 +41,6 @@ struct ProfileBottomSheet: View {
41
41
42
42
@Environment ( \. isHorizontal) private var isHorizontal
43
43
44
- private var maxWidth : CGFloat {
45
- idiom == . pad || ( idiom == . phone && isHorizontal) ? 330 : . infinity
46
- }
47
-
48
44
init (
49
45
showingBottomSheet: Binding < Bool > ,
50
46
openGallery: @escaping ( ) -> Void ,
@@ -56,84 +52,74 @@ struct ProfileBottomSheet: View {
56
52
}
57
53
58
54
var body : some View {
59
- GeometryReader { proxy in
60
- ZStack ( alignment: . bottom) {
61
- if showingBottomSheet {
62
- background
63
- . onTapGesture {
64
- withAnimation {
65
- showingBottomSheet = false
66
- }
55
+ ZStack ( alignment: . bottom) {
56
+ if showingBottomSheet {
57
+ Color . black. opacity ( 0.5 )
58
+ . ignoresSafeArea ( )
59
+ . onTapGesture {
60
+ withAnimation {
61
+ showingBottomSheet = false
67
62
}
68
- }
69
- content
70
- . offset ( y: showingBottomSheet ? yPosition : proxy. size. height)
71
- . gesture ( dragGesture)
63
+ }
72
64
}
73
- . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . center)
74
- }
75
- }
76
-
77
- private var background : some View {
78
- Color . black
79
- . opacity ( 0.5 )
80
- . ignoresSafeArea ( )
81
- }
82
-
83
- private var content : some View {
84
- VStack {
85
65
VStack {
86
- VStack ( alignment: . center, spacing: 4 ) {
87
- HStack ( alignment: . center) {
88
- RoundedRectangle ( cornerRadius: 2 , style: . circular)
89
- . foregroundColor ( Theme . Colors. textSecondary)
90
- . frame ( width: 31 , height: 4 )
91
- . padding ( . top, 4 )
92
- }
93
- . frame ( maxWidth: . infinity)
94
-
95
- Text ( ProfileLocalization . Edit. BottomSheet. title)
96
- . font ( Theme . Fonts. titleLarge)
97
- . frame ( maxWidth: . infinity, alignment: . leading)
98
- . padding ( . vertical, 14 )
99
- . accessibilityIdentifier ( " profile_bottom_sheet_title_text " )
100
-
101
- button ( title: ProfileLocalization . Edit. BottomSheet. select,
102
- type: . gallery,
103
- action: {
104
- openGallery ( )
105
- } )
106
- . accessibilityIdentifier ( " select_picture_button " )
107
-
108
- button ( title: ProfileLocalization . Edit. BottomSheet. remove,
109
- type: . remove,
110
- action: {
111
- removePhoto ( )
112
- } )
113
- . padding ( . top, 10 )
114
- . accessibilityIdentifier ( " remove_picture_button " )
66
+ VStack {
67
+ VStack ( alignment: . center, spacing: 4 ) {
68
+ HStack ( alignment: . center) {
69
+ RoundedRectangle ( cornerRadius: 2 , style: . circular)
70
+ . foregroundColor ( Theme . Colors. textSecondary)
71
+ . frame ( width: 31 , height: 4 )
72
+ . padding ( . top, 4 )
73
+ } . frame ( maxWidth: . infinity)
74
+
75
+ Text ( ProfileLocalization . Edit. BottomSheet. title)
76
+ . font ( Theme . Fonts. titleLarge)
77
+ . frame ( maxWidth: . infinity, alignment: . leading)
78
+ . padding ( . vertical, 14 )
79
+ . accessibilityIdentifier ( " profile_bottom_sheet_title_text " )
80
+
81
+ button ( title: ProfileLocalization . Edit. BottomSheet. select,
82
+ type: . gallery,
83
+ action: {
84
+ openGallery ( )
85
+ } )
86
+ . accessibilityIdentifier ( " select_picture_button " )
87
+
88
+ button ( title: ProfileLocalization . Edit. BottomSheet. remove,
89
+ type: . remove,
90
+ action: {
91
+ removePhoto ( )
92
+ } )
93
+ . padding ( . top, 10 )
94
+ . accessibilityIdentifier ( " remove_picture_button " )
95
+
96
+ button ( title: ProfileLocalization . Edit. BottomSheet. cancel,
97
+ type: . cancel,
98
+ action: {
99
+ withAnimation {
100
+ showingBottomSheet = false
101
+ }
102
+ } )
103
+ . padding ( . top, 34 )
104
+ . accessibilityIdentifier ( " cancel_button " )
105
+ } . padding ( . horizontal, 24 )
115
106
116
- button ( title: ProfileLocalization . Edit. BottomSheet. cancel,
117
- type: . cancel,
118
- action: {
119
- withAnimation {
120
- showingBottomSheet = false
121
- }
122
- } )
123
- . padding ( . top, 34 )
124
- . accessibilityIdentifier ( " cancel_button " )
125
107
}
126
- . padding ( . horizontal, 24 )
108
+ . frame ( minWidth: 0 ,
109
+ maxWidth: ( idiom == . pad || ( idiom == . phone && isHorizontal) )
110
+ ? 330
111
+ : . infinity,
112
+ maxHeight: 290 , alignment: . topLeading)
113
+ . background ( Theme . Colors. cardViewBackground)
114
+ . cornerRadius ( 8 )
115
+ . padding ( . horizontal, 22 )
127
116
}
128
- . frame ( minWidth: 0 ,
129
- maxWidth: maxWidth,
130
- maxHeight: 290 , alignment: . topLeading)
131
- . background ( Theme . Colors. cardViewBackground)
132
- . cornerRadius ( 8 )
133
- . padding ( . horizontal, 22 )
134
- }
117
+ . offset ( y: showingBottomSheet ? yPosition : 700 )
118
+ . gesture ( dragGesture)
119
+ } . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . center)
135
120
}
136
-
121
+
122
+ @ViewBuilder
137
123
private func button( title: String , type: ButtonType , action: @escaping ( ) -> Void ) -> some View {
138
124
Button ( action: action) {
139
125
HStack ( alignment: . center) {
0 commit comments