This commit is contained in:
2024-12-30 08:01:17 +01:00
parent dfafeecf2c
commit 7894f7d420
218 changed files with 8981 additions and 20 deletions

View File

@@ -0,0 +1,25 @@
module main
import freeflowuniverse.herolib.console
fn do() ! {
mut c:=console.new()
r:=c.ask_question(question:"my question")!
println(r)
r2:=c.ask_dropdown_multiple(question:"my dropdown",items:["a","b","c"])!
println(r2)
r3:=c.ask_dropdown_multiple(question:"my dropdown",items:["a","b","c"],default:["a","b"],clear:true)!
println(r3)
r3:=c.ask_dropdown(question:"my dropdown",items:["a","b","c"],default:["c"],clear:true)!
println(r3)
}
fn main() {
do() or { panic(err) }
}

View File

@@ -0,0 +1,54 @@
module main
import freeflowuniverse.herolib.ui
import freeflowuniverse.herolib.ui.generic
struct RoomOrderFlow {
pub mut:
current_product string
ui generic.UserInterface
}
fn (mut f RoomOrderFlow) room_choice() ! {
i := f.ui.ask_dropdown(
description: 'Which type of room do you want?'
items: ['penthouse', 'normal', 'single', 'appartment_room']
warning: 'Please select your right type of room'
)!
println(i)
smoker := f.ui.ask_yesno(description: 'Are you a smoker?')!
if smoker {
smoke := f.ui.ask_yesno(description: 'Do you want to smoke in your room?')!
if smoke == false {
println('Please realize if we detect you have smoked in your room we will charge 100USD to deep clean the room.')
}
}
if smoker == false {
// TODO check there is a non smoking room.
println("We are very sorry, we didn't find a non smoking room, do you want another room or you are ok.")
} else {
println("We are a non smoking hotel, we're sorry.")
}
}
fn do() ! {
// all bool // means user can choose all of them
// description string
// items []string
// warning string
// reset bool = true
gui := ui.new(channel: .console)!
mut f := RoomOrderFlow{
ui: gui
}
f.room_choice()!
// println(i)
}
fn main() {
do() or { panic(err) }
}

45
examples/ui/flow1.v Normal file
View File

@@ -0,0 +1,45 @@
module main
import freeflowuniverse.herolib.ui
struct RoomOrderFlow {
current_product string
ui ui.UserInterface
}
fn (mut f RoomOrderFlow) room_select() ! {
i := f.ui.ask_dropdown_int(
description: 'Which type of room do you want?'
items: ['penthouse', 'normal', 'single', 'appartment_room']
warning: 'Please select your right type of room'
reset: true
)
// match
smoker := f.ui.ask_yesno(description: 'Are you a smoker?')
if smoker {
smoke := f.ui.ask_yesno(description: 'Do you want to smoke in your room?')
if smoke == false {
println('Please realize if we detect you have smoked in your room we will charge 100USD to deep clean the room.')
}
}
if smoker == false {
// TODO check there is a non smoking room.
if false {
println("We are very sorry, we didn't find a non smoking room, do you want another room or you are ok.")
}
}
}
fn do() ! {
// open your flow and attach the required channel to it
mut f := RoomOrderFlow{
ui: ui.new(.console)
}
f.room_select()!
// println(i)
}
fn main() {
do() or { panic(err) }
}

14
examples/ui/silence.vsh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
console.silent_set()
mut job2 := osal.exec(cmd: 'ls /',debug:true)!
println("I got nothing above")
console.silent_unset()
println("now I will get output")
osal.exec(cmd: 'ls /',debug:true)!

View File

@@ -0,0 +1,49 @@
module main
import freeflowuniverse.herolib.ui.console
struct RoomOrderFlow {
current_product string
ui UserInterface
}
fn (mut f RoomOrderFlow) room_choice() ! {
i := ui.ask_dropdown(
description: 'Which type of room do you want?'
items: ['penthouse', 'normal', 'single', 'appartment_room']
warning: 'Please select your right type of room'
reset: true
)
// match
smoker := console.ask_yesno(description: 'Are you a smoker?')
if smoker {
smoke := console.ask_yesno(description: 'Do you want to smoke in your room?')
if smoke == false {
println('Please realize if we detect you have smoked in your room we will charge 100USD to deep clean the room.')
}
}
if smoker == false {
// TODO check there is a non smoking room.
if false {
println("We are very sorry, we didn't find a non smoking room, do you want another room or you are ok.")
}
}
}
fn do() ! {
// all bool // means user can choose all of them
// description string
// items []string
// warning string
// reset bool = true
mut f := RoomOrderFlow{}
f.room_choice()!
// println(i)
}
fn main() {
do() or { panic(err) }
}