-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
92 lines (78 loc) · 2.42 KB
/
Copy pathmain.go
File metadata and controls
92 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import (
"fmt"
"github.com/base-go/GoFlow/pkg/ui/adaptive"
"github.com/base-go/GoFlow/pkg/core/framework"
"github.com/base-go/GoFlow/pkg/core/widgets"
)
// AdaptiveDemoApp demonstrates platform-adaptive widgets
type AdaptiveDemoApp struct {
goflow.BaseWidget
}
func (a *AdaptiveDemoApp) Build(context goflow.BuildContext) goflow.Widget {
platform := goflow.GetPlatform()
// Create adaptive widgets that will look native on each platform
return &widgets.Column{
Children: []goflow.Widget{
// Adaptive AppBar - will be Material AppBar or Cupertino NavigationBar
adaptive.NewAppBar(&widgets.Text{
Data: "Adaptive Demo",
}),
// Platform info card
adaptive.NewCard(&widgets.Column{
Children: []goflow.Widget{
&widgets.Text{
Data: fmt.Sprintf("Current Platform: %s", platform.String()),
},
&widgets.Text{
Data: fmt.Sprintf("Design System: %s", platform.DefaultTheme()),
},
},
}),
// Buttons demo card
adaptive.NewCard(&widgets.Column{
Children: []goflow.Widget{
&widgets.Text{
Data: "Adaptive Buttons",
},
// Filled button
adaptive.NewButton("Filled Button", func() {
fmt.Println("Filled button clicked!")
}),
// Text button
adaptive.NewTextButton("Text Button", func() {
fmt.Println("Text button clicked!")
}),
// Outlined button (Material only, will be gray on iOS)
&adaptive.Button{
Text: "Outlined Button",
Style: adaptive.ButtonStyleOutlined,
OnPressed: func() {
fmt.Println("Outlined button clicked!")
},
},
},
}),
// Info card
adaptive.NewCard(&widgets.Text{
Data: "This UI adapts automatically to your platform. " +
"On iOS/macOS it uses Cupertino widgets, " +
"on other platforms it uses Material Design.",
}),
},
}
}
func main() {
fmt.Println("GoFlow Adaptive Widget Demo")
fmt.Printf("Platform: %s\n", goflow.GetPlatform().String())
fmt.Printf("Design System: %s\n", goflow.GetPlatform().DefaultTheme())
fmt.Println()
fmt.Println("This example demonstrates platform-adaptive widgets.")
fmt.Println("The same code automatically switches between Material and Cupertino styles.")
fmt.Println()
// Uncomment to test different platforms:
// goflow.SetPlatform(goflow.PlatformIOS)
// goflow.SetPlatform(goflow.PlatformAndroid)
app := &AdaptiveDemoApp{}
_ = app // In a real app, this would be passed to the GoFlow runtime
}