Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,50 @@ plugins:
# - vendor/cache/
# - vendor/gems/
# - vendor/ruby/

logo: "/docs/assets/images/logo-gst.ico"

search_enabled: true

search:
# Split pages into sections that can be searched individually
# Supports 1 - 6, default: 2
heading_level: 2
# Maximum amount of previews per search result
# Default: 3
previews: 3
# Maximum amount of words to display before a matched word in the preview
# Default: 5
preview_words_before: 5
# Maximum amount of words to display after a matched word in the preview
# Default: 10
preview_words_after: 10
# Set the search token separator
# Default: /[\s\-/]+/
# Example: enable support for hyphenated search words
tokenizer_separator: /[\s/]+/
# Display the relative url in search results
# Supports true (default) or false
rel_url: true
# Enable or disable the search button that appears in the bottom right corner of every page
# Supports true or false (default)
button: false

# Aux links for the upper right navigation
aux_links:
"TechOver.io":
- "//techover.io"

# Back to top link
back_to_top: true
back_to_top_text: "Back to top"

ga_tracking: G-NTC0J1J3N2

plugins:
- jekyll-seo-tag

kramdown:
syntax_highlighter_opts:
block:
line_numbers: false
Binary file added docs/assets/images/logo-gst.ico
Binary file not shown.
Binary file added docs/assets/images/logo-gst.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: default
title: Overview
nav_order: 2
---

Overview
25 changes: 25 additions & 0 deletions docs/swiftui_components/SwiftUI-Button.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: default
title: Button
parent: SwiftUI's components
nav_order: 4
---

```swift
struct ContentView: View {
@State private var showDetails = false

var body: some View {
VStack(alignment: .leading) {
Button("Show details") {
showDetails.toggle()
}

if showDetails {
Text("You should follow me on Twitter: @twostraws")
.font(.largeTitle)
}
}
}
}
```
83 changes: 83 additions & 0 deletions docs/swiftui_components/SwiftUI-List.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: default
title: List
parent: SwiftUI's components
nav_order: 4
---

```swift
struct SongRow: View {
var song: Song
@Binding var isPlaying: Bool

var body: some View {
HStack {
VStack(alignment: .leading) {
Text(song.name).bold()
Text(song.artist.name)
}
Spacer()
Button(
action: { self.isPlaying.toggle() },
label: {
if isPlaying {
PauseIcon()
} else {
PlayIcon()
}
}
)
}
}
}
```

Co the tach phan cac label cua button ra nhu duoi

```swift
private extension SongRow {
func makeButtonLabel() -> some View {
if isPlaying {
return AnyView(PauseIcon())
} else {
return AnyView(PlayIcon())
}
}
}
```

Chỗ này phải return AnyView vì thằng PauseIcon và PlayIcon khác type nhau

Có một cách khác để xử lý vấn đề trên như sau:

```swift
private extension SongRow {
@ViewBuilder func makeButtonLabel() -> some View {
if isPlaying {
PauseIcon()
} else {
PlayIcon()
}
}
}
```

Với ViewBuilder thì ta không cần phải dùng AnyView nữa

Lúc này có thể call như thằng

```swift
struct SongRow: View {
...

var body: some View {
HStack {
...
Button(
action: { self.isPlaying.toggle() },
label: { makeButtonLabel() }
)
}
}
}
```
8 changes: 8 additions & 0 deletions docs/swiftui_components/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: default
title: SwiftUI's components
nav_order: 4
has_children: true
---

SwiftUI Components
29 changes: 29 additions & 0 deletions docs/uikit_to_swiftui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
layout: default
title: UIKit to SwiftUI
nav_order: 3
---

| UIKit | Swift UI |
| ------------- | ------------- |
| UITableView | List |
| UILabel | Text |
| UITextField | TextField |
| UITextField secure | SecureField |
| UISwitch | Toggle |
| UISlider | Slider |
| UIButton | Button |
| UINavigationController | NavigationView |
| UIAlertController alert | Alert |
| UIAlertController action sheet | Action Sheet |
| UIStackView horizontal | HStack |
| UIStackView vertical | VStack |
| UIImageView | Image |
| UISegmentedControl | SegmentedControl |
| UIStepper | Stepper |
| UIDatePicker | DatePicker |
| UICollectionView | Not yet |
| UITextView | Not yet |
| | |
| UITableView section | Section |
| UIViewController | Combine |
6 changes: 0 additions & 6 deletions index.markdown

This file was deleted.

20 changes: 20 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: default
title: Home
nav_order: 1
description: "SwiftUI Journey, all about SwiftUI's components, which we worked with or studied about."
permalink: /
---

## About GST

![GST's Logo](docs/assets/images/logo-gst.png "GST's Logo"){:height="40px" width="40px" .centered-image}

## Why SwiftUI

## Contributors

- [nhathm](https://github.com/nhathm){:target="_blank"}
- [tamnxh](https://github.com/tamnxh){:target="_blank"}

**[Main Page](https://techover.io/)**