Last active
July 3, 2020 13:32
-
-
Save MrRooni/3ce8e377e21f424299b69b945f973092 to your computer and use it in GitHub Desktop.
Revisions
-
MrRooni revised this gist
Jul 3, 2020 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,4 +45,6 @@ This works!  However, this approach feels kludgy. **My question to you, dear forum frequenters: Is there a better way? Perhaps using alignment guides or another tool I'm not yet aware of?** -
MrRooni revised this gist
Jul 3, 2020 . 1 changed file with 19 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ I have a basic List row I am building that has a large number on the leading edge followed by a title and subtitle next to it:  I started with a simple implementation, like so: ```swift HStack { Text("26") @@ -14,21 +18,31 @@ HStack { } ``` However, because different numbers have different widths my alignment is less than ideal when viewed in the List:  To correct this I ended up using a GeometryReader to grab the height of the row, pad it by 20%, and set that as the width of the number text, like so: ```swift GeometryReader { geometry in HStack { Text("26") .font(.title) .frame(width: geometry.size.height * 1.2) VStack(alignment: .leading) { Text("Some title") .font(.body) .bold() Text("Some subtitle") .font(.caption) } } } ``` This works!  However, this approach feels kludgy. Is there a better way, perhaps using alignment guides? -
MrRooni created this gist
Jul 3, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ I have a basic List row I am building that has a large number on the leading edge followed by a title and subtitle next to it: ```swift HStack { Text("26") .font(.title) VStack(alignment: .leading) { Text("Some title") .font(.body) .bold() Text("Some subtitle") .font(.caption) } } ``` The trouble I'm running into is ```swift GeometryReader { geometry in HStack { Text(weekNumberDateFormatter.string(from: self.note.identifier)) .font(.title) .frame(width: geometry.size.height * 1.2) VStack(alignment: .leading) { Text(self.note.firstTextRowText()) .font(.body) .bold() Text(self.note.secondTextRowText()) .font(.caption) } } } ```