@@ -9,6 +9,7 @@ import SwiftUI
99
1010struct TodoManageView : View {
1111 @State var viewModel : TodoManageViewModel
12+ @State private var tmpText : String = " "
1213 var onDismiss : ( ( [ TodoCategoryPreference ] ) -> Void ) ?
1314
1415 var body : some View {
@@ -23,6 +24,7 @@ struct TodoManageView: View {
2324 viewModel. send ( . tapItem( category) )
2425 }
2526 Text ( category. localizedName)
27+ . lineLimit ( 1 )
2628 Spacer ( )
2729 if case . user = category {
2830 Button {
@@ -102,22 +104,34 @@ struct TodoManageView: View {
102104 NavigationStack {
103105 Form {
104106 Section {
105- TextField (
106- " 카테고리명 " ,
107- text : Binding (
108- get : { viewModel . state . category ? . name ?? " " } ,
109- set : { viewModel. send ( . setCategoryName ( $0 ) ) }
107+ HStack ( spacing : 8 ) {
108+ TextField (
109+ " " ,
110+ text : $tmpText ,
111+ prompt : Text ( viewModel. placerholder ) . foregroundStyle ( . secondary )
110112 )
111- )
112- . frame ( height: UIFont . preferredFont ( forTextStyle: . body) . lineHeight)
113+ . frame ( height: UIFont . preferredFont ( forTextStyle: . body) . lineHeight)
114+ . onAppear {
115+ tmpText = viewModel. state. category? . name ?? " "
116+ }
117+ . onChange ( of: tmpText) { _, value in
118+ viewModel. send ( . setCategoryName( value) )
119+ tmpText = viewModel. state. category? . name ?? " "
120+ }
121+
122+ Text ( viewModel. categoryNameCountText)
123+ . font ( . footnote)
124+ . foregroundStyle ( . secondary)
125+ . monospacedDigit ( )
126+ }
113127 }
114128
115129 Section {
130+ let color = Color ( hexString: viewModel. state. category? . colorHex ?? " #0A84FF " ) ?? . blue
116131 ColorPicker ( selection: Binding (
117- get: { Color ( hexString : viewModel . state . category ? . colorHex ?? " #0A84FF " ) ?? . blue } ,
132+ get: { color } ,
118133 set: { viewModel. send ( . setCategoryColor( $0) ) }
119134 ) , supportsOpacity: false ) {
120- let color = Color ( hexString: viewModel. state. category? . colorHex ?? " #0A84FF " ) ?? . blue
121135 Text ( viewModel. state. category? . colorHex ?? " # " )
122136 . foregroundStyle ( color)
123137 }
0 commit comments