This file contains 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 characters
// Note: The type of body is: ModifiedContent<VStack<TupleView<(Text, Button<Text>, Text)>>, _PaddingLayout> | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
Text("Hello, world! (1)") | |
Button("print my type") { | |
print(type(of: self.body)) | |
} | |
Text("Hello, world! (2)") |
This file contains 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 characters
public protocol Shape { | |
associatedtype T | |
func draw() -> String | |
} | |
class Triangle: Shape { | |
typealias T = Int | |
func draw() -> String { | |
return "Triangle" |
This file contains 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 characters
public protocol Shape { | |
func draw() -> String | |
} | |
struct Triangle: Shape { | |
typealias T = Int | |
var size: Int | |
func draw() -> String { | |
var result: [String] = [] |
This file contains 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 characters
public protocol Shape { | |
associatedtype T | |
func draw() -> String | |
} | |
struct Triangle: Shape { | |
typealias T = Int | |
var size: Int | |
func draw() -> String { |
This file contains 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 characters
protocol Shape { | |
associatedtype T | |
func draw() -> String | |
} | |
struct Triangle: Shape { | |
typealias T = Int | |
var size: Int | |
func draw() -> String { |
This file contains 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 characters
protocol Shape { | |
associatedtype T | |
func draw() -> String | |
} | |
struct Triangle: Shape { | |
typealias T = Int | |
var size: Int | |
func draw() -> String { |
This file contains 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 characters
func toGmtDate(year: Int, month: Int, date: Int, hour: Int, minute: Int, second: Int) -> Date? { | |
let str = String(format: "%04d-%02d-%02d %02d:%02d:%02d+0800", | |
year, month, date, | |
hour, minute, second) | |
let dateFormatter = DateFormatter() | |
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ssZ" | |
dateFormatter.locale = Locale(identifier: "en_US_POSIX") // Set locale to POSIX | |
if let date = dateFormatter.date(from: str) { |
This file contains 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 characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>App 頁面</title> | |
<style> | |
body { | |
margin: 0; | |
display: flex; |
This file contains 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 characters
import androidx.appcompat.app.AppCompatActivity; | |
import android.graphics.Color; | |
import android.graphics.drawable.GradientDrawable; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
import android.widget.Button; | |
public class MainActivity extends AppCompatActivity { |
This file contains 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 characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<WebView | |
android:id="@+id/webview" |
NewerOlder