@@ -35,123 +35,119 @@ struct TimeRangeSelectionSheet: View {
3535 }
3636
3737 var body : some View {
38- NavigationView {
39- VStack ( alignment: . leading, spacing: 0 ) {
40- Spacer ( ) . frame ( height: 10 )
41-
42- Group {
43- HStack ( spacing: 8 ) {
44- Button {
45- selectedBlockMask = TimetablePainter . toBlockMask ( from: currentTimetable. timeMask. filter { $0. day < 5 } , reverse: true )
46- } label: {
47- HStack ( spacing: 0 ) {
48- Image ( " timerange.magicwand " )
49- Text ( " 빈시간대 선택하기 " )
50- . font ( . system( size: 13 , weight: . medium) )
51- . foregroundColor ( colorScheme == . dark ? STColor . gray20 : . white)
52- }
53- . padding ( . leading, 6 )
54- . padding ( . trailing, 8 )
38+ VStack ( alignment: . leading, spacing: 0 ) {
39+ Spacer ( ) . frame ( height: 10 )
40+
41+ Group {
42+ HStack ( spacing: 8 ) {
43+ Button {
44+ selectedBlockMask = TimetablePainter . toBlockMask ( from: currentTimetable. timeMask. filter { $0. day < 5 } , reverse: true )
45+ } label: {
46+ HStack ( spacing: 0 ) {
47+ Image ( " timerange.magicwand " )
48+ Text ( " 빈시간대 선택하기 " )
49+ . font ( . system( size: 13 , weight: . medium) )
50+ . foregroundColor ( colorScheme == . dark ? STColor . gray20 : . white)
5551 }
56- . background ( Rectangle ( )
57- . frame ( height: 24 )
58- . cornerRadius ( 6 )
59- . foregroundColor ( colorScheme == . dark ? STColor . darkerGray : STColor . gray2)
60- )
52+ . padding ( . leading, 6 )
53+ . padding ( . trailing, 8 )
54+ }
55+ . background ( Rectangle ( )
56+ . frame ( height: 24 )
57+ . cornerRadius ( 6 )
58+ . foregroundColor ( colorScheme == . dark ? STColor . darkerGray : STColor . gray2)
59+ )
6160
62- Button {
63- resetTemporary ( )
64- resetSelected ( )
65- } label: {
66- HStack ( spacing: 0 ) {
67- Image ( " timerange.reset " )
68- Text ( " 초기화 " )
69- . font ( . system( size: 14 ) )
70- . foregroundColor ( colorScheme == . dark ? STColor . gray30 : STColor . gray20)
71- }
61+ Button {
62+ resetTemporary ( )
63+ resetSelected ( )
64+ } label: {
65+ HStack ( spacing: 0 ) {
66+ Image ( " timerange.reset " )
67+ Text ( " 초기화 " )
68+ . font ( . system( size: 14 ) )
69+ . foregroundColor ( colorScheme == . dark ? STColor . gray30 : STColor . gray20)
7270 }
73- . buttonStyle ( DefaultButtonStyle ( ) )
7471 }
72+ . buttonStyle ( DefaultButtonStyle ( ) )
73+ }
7574
76- Spacer ( ) . frame ( height: 16 )
75+ Spacer ( ) . frame ( height: 16 )
7776
78- Text ( " 드래그하여 시간대를 선택해보세요. " )
79- . font ( . system( size: 14 ) )
80- . foregroundColor ( colorScheme == . dark ? STColor . darkGray : STColor . gray20)
81- }
82- . padding ( . horizontal, 10 )
77+ Text ( " 드래그하여 시간대를 선택해보세요. " )
78+ . font ( . system( size: 14 ) )
79+ . foregroundColor ( colorScheme == . dark ? STColor . darkGray : STColor . gray20)
80+ }
81+ . padding ( . horizontal, 10 )
8382
84- Spacer ( ) . frame ( height: 10 )
83+ Spacer ( ) . frame ( height: 10 )
8584
86- GeometryReader { reader in
87- ZStack ( alignment: . topLeading) {
88- TimetableGridLayer ( current: currentTimetable, config: config)
89- GrayScaledTimetableBlocksLayer
90- selectedTimeRangeBlocksLayer ( in: reader. size)
91- temporaryTimeRangeBlocksLayer ( in: reader. size)
92- }
93- . contentShape ( Rectangle ( ) )
94- . gesture (
95- DragGesture ( minimumDistance: 0 )
96- . onChanged { gesture in
97- let start = gesture. startLocation
98- let current = gesture. location
99- if outOfBounds ( point: start, in: reader. size) || outOfBounds ( point: current, in: reader. size) {
100- return
101- }
85+ GeometryReader { reader in
86+ ZStack ( alignment: . topLeading) {
87+ TimetableGridLayer ( current: currentTimetable, config: config)
88+ GrayScaledTimetableBlocksLayer
89+ selectedTimeRangeBlocksLayer ( in: reader. size)
90+ temporaryTimeRangeBlocksLayer ( in: reader. size)
91+ }
92+ . contentShape ( Rectangle ( ) )
93+ . gesture (
94+ DragGesture ( minimumDistance: 0 )
95+ . onChanged { gesture in
96+ let start = gesture. startLocation
97+ let current = gesture. location
98+ if outOfBounds ( point: start, in: reader. size) || outOfBounds ( point: current, in: reader. size) {
99+ return
100+ }
102101
103- let currentBlockMask = TimetablePainter . toggleOnBlockMask ( at: gesture. location, in: reader. size)
104- temporaryBlockMask = temporaryBlockMask. enumerated ( ) . map {
105- $0. element || currentBlockMask [ $0. offset]
106- }
102+ let currentBlockMask = TimetablePainter . toggleOnBlockMask ( at: gesture. location, in: reader. size)
103+ temporaryBlockMask = temporaryBlockMask. enumerated ( ) . map {
104+ $0. element || currentBlockMask [ $0. offset]
105+ }
106+ }
107+ . onEnded { gesture in
108+ let start = gesture. startLocation
109+ let end = gesture. location
110+ if outOfBounds ( point: start, in: reader. size) || outOfBounds ( point: end, in: reader. size) {
111+ return
107112 }
108- . onEnded { gesture in
109- let start = gesture. startLocation
110- let end = gesture. location
111- if outOfBounds ( point: start, in: reader. size) || outOfBounds ( point: end, in: reader. size) {
112- return
113- }
114113
115- selectMode = !TimetablePainter. isSelected ( point: start, blockMask: selectedBlockMask, in: reader. size)
116- if selectMode {
117- selectedBlockMask = selectedBlockMask. enumerated ( ) . map {
118- $0. element || temporaryBlockMask [ $0. offset]
119- }
120- } else {
121- selectedBlockMask = selectedBlockMask. enumerated ( ) . map {
122- $0. element && !temporaryBlockMask[ $0. offset]
123- }
114+ selectMode = !TimetablePainter. isSelected ( point: start, blockMask: selectedBlockMask, in: reader. size)
115+ if selectMode {
116+ selectedBlockMask = selectedBlockMask. enumerated ( ) . map {
117+ $0. element || temporaryBlockMask [ $0. offset]
118+ }
119+ } else {
120+ selectedBlockMask = selectedBlockMask. enumerated ( ) . map {
121+ $0. element && !temporaryBlockMask[ $0. offset]
124122 }
125- resetTemporary ( )
126123 }
127- )
128- }
124+ resetTemporary ( )
125+ }
126+ )
129127 }
130- . padding ( . horizontal , 20 )
131- . toolbar {
132- ToolbarItem ( placement : . cancellationAction ) {
133- Button {
134- dismiss ( )
135- } label : {
136- Text ( " 취소 " )
137- }
128+ }
129+ . padding ( . horizontal , 20 )
130+ . toolbar {
131+ ToolbarItem ( placement : . cancellationAction ) {
132+ Button {
133+ dismiss ( )
134+ } label : {
135+ Text ( " 취소 " )
138136 }
137+ }
139138
140- ToolbarItem ( placement: . confirmationAction) {
141- Button {
142- selectedTimeRange = TimetablePainter . getSelectedTimeRange ( from: selectedBlockMask)
143- selectTimeRangeTag ( )
144- dismiss ( )
145- } label: {
146- Text ( " 완료 " )
147- }
139+ ToolbarItem ( placement: . confirmationAction) {
140+ Button {
141+ selectedTimeRange = TimetablePainter . getSelectedTimeRange ( from: selectedBlockMask)
142+ selectTimeRangeTag ( )
143+ dismiss ( )
144+ } label: {
145+ Text ( " 완료 " )
148146 }
149147 }
150- . background ( STColor . systemBackground)
151148 }
152- . foregroundColor ( . primary)
153- . interactiveDismissDisabled ( )
154- . ignoresSafeArea ( . keyboard)
149+ . padding ( . bottom, 16 )
150+ . background ( STColor . systemBackground)
155151 }
156152
157153 private var GrayScaledTimetableBlocksLayer : some View {
0 commit comments