-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
150 lines (133 loc) · 3.91 KB
/
Copy pathmain.go
File metadata and controls
150 lines (133 loc) · 3.91 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package main
import (
"fmt"
"github.com/base-go/GoFlow/pkg/core/framework"
"github.com/base-go/GoFlow/pkg/ui/material"
"github.com/base-go/GoFlow/pkg/core/widgets"
)
// WidgetsShowcaseApp demonstrates all available widgets
type WidgetsShowcaseApp struct {
goflow.BaseWidget
}
func (w *WidgetsShowcaseApp) Build(context goflow.BuildContext) goflow.Widget {
return &material.Scaffold{
AppBar: material.NewAppBar(&widgets.Text{
Data: "GoFlow Widgets Showcase",
}),
Body: &widgets.SingleChildScrollView{
Child: &widgets.Column{
Children: []goflow.Widget{
// Layout Widgets Section
buildSectionHeader("Layout Widgets"),
// Stack example
material.NewCard(&widgets.Container{
Padding: goflow.NewEdgeInsets(16, 16, 16, 16),
Child: &widgets.Column{
Children: []goflow.Widget{
&widgets.Text{Data: "Stack Example"},
&widgets.Stack{
Children: []goflow.Widget{
&widgets.Container{
Width: floatPtr(200),
Height: floatPtr(100),
Color: goflow.NewColor(200, 200, 255, 255),
},
&widgets.Align{
Alignment: widgets.AlignmentCenter,
Child: &widgets.Text{
Data: "Centered Text",
},
},
},
Fit: widgets.StackFitLoose,
},
},
},
}),
// Buttons Section
buildSectionHeader("Buttons"),
material.NewCard(&widgets.Container{
Padding: goflow.NewEdgeInsets(16, 16, 16, 16),
Child: &widgets.Row{
Children: []goflow.Widget{
material.NewButton(&widgets.Text{Data: "Filled"}, func() {
fmt.Println("Filled button clicked")
}),
material.NewTextButton("Text", func() {
fmt.Println("Text button clicked")
}),
material.NewOutlinedButton("Outlined", func() {
fmt.Println("Outlined button clicked")
}),
},
MainAxisAlignment: widgets.MainAxisSpaceAround,
},
}),
// Form Widgets Section
buildSectionHeader("Form Widgets"),
material.NewCard(&widgets.Container{
Padding: goflow.NewEdgeInsets(16, 16, 16, 16),
Child: &widgets.Column{
Children: []goflow.Widget{
&widgets.Text{Data: "Checkbox & Switch"},
material.NewCheckbox(true, func(b bool) {
fmt.Println("Checkbox:", b)
}),
material.NewSwitch(true, func(b bool) {
fmt.Println("Switch:", b)
}),
},
},
}),
// Icons Section
buildSectionHeader("Icons"),
material.NewCard(&widgets.Container{
Padding: goflow.NewEdgeInsets(16, 16, 16, 16),
Child: &widgets.Row{
Children: []goflow.Widget{
widgets.NewIcon(widgets.IconHome),
widgets.NewIcon(widgets.IconFavorite),
widgets.NewIcon(widgets.IconSearch),
widgets.NewIcon(widgets.IconSettings),
},
MainAxisAlignment: widgets.MainAxisSpaceAround,
},
}),
// List Tiles Section
buildSectionHeader("List Tiles"),
material.NewListTile(&widgets.Text{Data: "List Tile 1"}),
material.NewListTile(&widgets.Text{Data: "List Tile 2"}),
material.NewListTile(&widgets.Text{Data: "List Tile 3"}),
},
},
},
FloatingActionButton: material.NewFloatingActionButton(
widgets.NewIcon(widgets.IconAdd),
func() {
fmt.Println("FAB clicked!")
},
),
}
}
func buildSectionHeader(title string) goflow.Widget {
return &widgets.Container{
Padding: goflow.NewEdgeInsets(16, 16, 16, 8),
Child: &widgets.Text{
Data: title,
Style: &goflow.TextStyle{
FontSize: 18.0,
Color: goflow.NewColor(33, 150, 243, 255),
},
},
}
}
func floatPtr(f float64) *float64 {
return &f
}
func main() {
fmt.Println("GoFlow Widgets Showcase")
fmt.Println("This example demonstrates all available widgets in GoFlow")
fmt.Println()
app := &WidgetsShowcaseApp{}
_ = app // In a real app, this would be passed to the GoFlow runtime
}