@@ -539,11 +539,11 @@ struct SettingsRow: View {
539539 var value : String
540540
541541 var body : some View {
542- HStack ( alignment: . firstTextBaseline, spacing: 18 ) {
542+ HStack ( alignment: . firstTextBaseline, spacing: 16 ) {
543543 Text ( label)
544- . font ( . callout)
544+ . font ( . callout. weight ( . medium ) )
545545 . foregroundStyle ( ElephantTheme . muted)
546- . frame ( width: 148 , alignment: . leading)
546+ . frame ( width: 132 , alignment: . leading)
547547 Text ( value)
548548 . font ( . callout)
549549 . foregroundStyle ( ElephantTheme . ink)
@@ -552,7 +552,8 @@ struct SettingsRow: View {
552552 . truncationMode ( . middle)
553553 . frame ( maxWidth: . infinity, alignment: . leading)
554554 }
555- . padding ( . vertical, 7 )
555+ . frame ( maxWidth: . infinity, minHeight: 34 , alignment: . leading)
556+ . padding ( . vertical, 5 )
556557 }
557558}
558559
@@ -572,21 +573,76 @@ struct SettingsFieldRow<Accessory: View>: View {
572573 }
573574
574575 var body : some View {
575- HStack ( alignment: . center, spacing: 18 ) {
576+ HStack ( alignment: . center, spacing: 16 ) {
576577 Text ( label)
577- . font ( . callout)
578+ . font ( . callout. weight ( . medium ) )
578579 . foregroundStyle ( ElephantTheme . muted)
579- . frame ( width: 148 , alignment: . leading)
580+ . frame ( width: 132 , alignment: . leading)
580581 Text ( value)
581582 . font ( . callout)
582583 . foregroundStyle ( ElephantTheme . ink)
583584 . textSelection ( . enabled)
584585 . lineLimit ( 1 )
585586 . truncationMode ( . middle)
586- Spacer ( minLength: 0 )
587+ . frame ( maxWidth: 260 , alignment: . leading)
588+ Spacer ( minLength: 12 )
587589 accessory
588590 }
589- . padding ( . vertical, 7 )
591+ . frame ( maxWidth: . infinity, minHeight: 34 , alignment: . leading)
592+ . padding ( . vertical, 5 )
593+ }
594+ }
595+
596+ private struct SettingsControlFieldModifier : ViewModifier {
597+ var width : CGFloat ?
598+ var minHeight : CGFloat
599+
600+ func body( content: Content ) -> some View {
601+ content
602+ . textFieldStyle ( . plain)
603+ . font ( . callout)
604+ . foregroundStyle ( ElephantTheme . ink)
605+ . padding ( . horizontal, 10 )
606+ . frame ( width: width, alignment: . center)
607+ . frame ( minHeight: minHeight, alignment: . center)
608+ . frame ( maxWidth: width == nil ? . infinity : width, alignment: . center)
609+ . background (
610+ Color ( nsColor: . controlBackgroundColor) . opacity ( 0.84 ) ,
611+ in: RoundedRectangle ( cornerRadius: 8 , style: . continuous)
612+ )
613+ . overlay (
614+ RoundedRectangle ( cornerRadius: 8 , style: . continuous)
615+ . stroke ( ElephantTheme . line. opacity ( 0.72 ) , lineWidth: 1 )
616+ )
617+ }
618+ }
619+
620+ private struct SettingsTextEditorModifier : ViewModifier {
621+ var minHeight : CGFloat
622+
623+ func body( content: Content ) -> some View {
624+ content
625+ . scrollContentBackground ( . hidden)
626+ . padding ( 8 )
627+ . frame ( minHeight: minHeight)
628+ . background (
629+ Color ( nsColor: . controlBackgroundColor) . opacity ( 0.84 ) ,
630+ in: RoundedRectangle ( cornerRadius: 8 , style: . continuous)
631+ )
632+ . overlay (
633+ RoundedRectangle ( cornerRadius: 8 , style: . continuous)
634+ . stroke ( ElephantTheme . line. opacity ( 0.72 ) , lineWidth: 1 )
635+ )
636+ }
637+ }
638+
639+ extension View {
640+ func settingsControlField( width: CGFloat ? = nil , minHeight: CGFloat = 34 ) -> some View {
641+ modifier ( SettingsControlFieldModifier ( width: width, minHeight: minHeight) )
642+ }
643+
644+ func settingsTextEditor( minHeight: CGFloat = 120 ) -> some View {
645+ modifier ( SettingsTextEditorModifier ( minHeight: minHeight) )
590646 }
591647}
592648
0 commit comments