the base
This commit is contained in:
49
lib/ui/generic/dropdown.v
Normal file
49
lib/ui/generic/dropdown.v
Normal file
@@ -0,0 +1,49 @@
|
||||
module generic
|
||||
|
||||
import freeflowuniverse.herolib.ui.console { UIConsole }
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel { DropDownArgs }
|
||||
|
||||
// return the dropdown as an int
|
||||
// description string
|
||||
// items []string
|
||||
// warning string
|
||||
// clear bool = true
|
||||
pub fn (mut c UserInterface) ask_dropdown(args DropDownArgs) !string {
|
||||
match mut c.channel {
|
||||
UIConsole { return c.channel.ask_dropdown(args)! }
|
||||
else { panic("can't find channel") }
|
||||
}
|
||||
}
|
||||
|
||||
// result can be multiple, aloso can select all
|
||||
// description string
|
||||
// items []string
|
||||
// warning string
|
||||
// clear bool = true
|
||||
pub fn (mut c UserInterface) ask_dropdown_multiple(args DropDownArgs) ![]string {
|
||||
match mut c.channel {
|
||||
UIConsole {
|
||||
return c.channel.ask_dropdown_multiple(args)!
|
||||
}
|
||||
else {
|
||||
panic("can't find channel")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// will return the string as given as response
|
||||
// description string
|
||||
// items []string
|
||||
// warning string
|
||||
// clear bool = true
|
||||
pub fn (mut c UserInterface) ask_dropdown_int(args DropDownArgs) !int {
|
||||
match mut c.channel {
|
||||
UIConsole {
|
||||
return c.channel.ask_dropdown_int(args)!
|
||||
}
|
||||
else {
|
||||
panic("can't find channel")
|
||||
}
|
||||
}
|
||||
}
|
||||
26
lib/ui/generic/editor.v
Normal file
26
lib/ui/generic/editor.v
Normal file
@@ -0,0 +1,26 @@
|
||||
module generic
|
||||
|
||||
// import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel
|
||||
|
||||
// open editor which can be used to edit content
|
||||
// (not every UI has all capability, in case of console open vscode if installed) .
|
||||
// .
|
||||
// ```
|
||||
// args:
|
||||
// content string //in specified format
|
||||
// cat ...
|
||||
// enum InfoCat {
|
||||
// content string //in specified format
|
||||
// cat EditorCat
|
||||
// }
|
||||
// ```
|
||||
// returns the editted content, idea is that formatting is used in editor
|
||||
pub fn (mut c UserInterface) edit(args uimodel.EditArgs) !string {
|
||||
// match mut c.channel {
|
||||
// UIConsole { return c.channel.editor(args)! }
|
||||
// else { panic("can't find channel") }
|
||||
// }
|
||||
return ''
|
||||
}
|
||||
37
lib/ui/generic/info.v
Normal file
37
lib/ui/generic/info.v
Normal file
@@ -0,0 +1,37 @@
|
||||
module generic
|
||||
|
||||
// import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel
|
||||
|
||||
// send info to the main pannel .
|
||||
// (not every UI has all capability e.g. html)
|
||||
//
|
||||
// ```
|
||||
// args:
|
||||
// content string //in specified format
|
||||
// clear bool //means screen is reset for content above
|
||||
// lf_before int //line feed before content
|
||||
// lf_after int
|
||||
// cat InfoCat
|
||||
// components []ComponentCat
|
||||
// enum InfoCat {
|
||||
// txt
|
||||
// html
|
||||
// markdown
|
||||
// }
|
||||
// MORE THAN ONE COMPONENT CAN BE ADDED TO INFO
|
||||
// enum ComponentCat {
|
||||
// bootstrap
|
||||
// htmx
|
||||
// bulma
|
||||
// }
|
||||
// ```
|
||||
// supports images, and other html elements
|
||||
// suggest to support htmx and limited js (how can we limit this)
|
||||
pub fn (mut c UserInterface) info(args uimodel.InfoArgs) ! {
|
||||
// match mut c.channel {
|
||||
// UIConsole { return c.channel.info(args)! }
|
||||
// else { panic("can't find channel") }
|
||||
// }
|
||||
}
|
||||
30
lib/ui/generic/log.v
Normal file
30
lib/ui/generic/log.v
Normal file
@@ -0,0 +1,30 @@
|
||||
module generic
|
||||
|
||||
// import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel
|
||||
|
||||
// log content to the log panel (not every UI has this capability)
|
||||
// ```
|
||||
// args:
|
||||
// content string
|
||||
// clear bool //means screen is reset for content above
|
||||
// lf_before int //line feed before content
|
||||
// lf_after int
|
||||
// cat LogCat
|
||||
// defines colors as used in the representation layer
|
||||
// enum LogCat {
|
||||
// info
|
||||
// log
|
||||
// warning
|
||||
// header
|
||||
// debug
|
||||
// error
|
||||
// }
|
||||
// ```
|
||||
pub fn (mut c UserInterface) log(args uimodel.LogArgs) ! {
|
||||
// match mut c.channel {
|
||||
// UIConsole { return c.channel.log(args)! }
|
||||
// else { panic("can't find channel") }
|
||||
// }
|
||||
}
|
||||
19
lib/ui/generic/model.v
Normal file
19
lib/ui/generic/model.v
Normal file
@@ -0,0 +1,19 @@
|
||||
module generic
|
||||
|
||||
import freeflowuniverse.herolib.ui.console { UIConsole }
|
||||
import freeflowuniverse.herolib.ui.template { UIExample }
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
|
||||
// need to do this for each type of UI channel e.g. console, telegram, ...
|
||||
type UIChannel = UIConsole | UIExample // TODO TelegramBot
|
||||
|
||||
pub struct UserInterface {
|
||||
pub mut:
|
||||
channel UIChannel
|
||||
user_id string
|
||||
}
|
||||
|
||||
pub enum ChannelType {
|
||||
console
|
||||
telegram
|
||||
}
|
||||
18
lib/ui/generic/payment.v
Normal file
18
lib/ui/generic/payment.v
Normal file
@@ -0,0 +1,18 @@
|
||||
module generic
|
||||
|
||||
// import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel
|
||||
|
||||
// ...
|
||||
// ```
|
||||
// args:
|
||||
// TODO
|
||||
// }
|
||||
// ```
|
||||
pub fn (mut c UserInterface) pay(args uimodel.PayArgs) ! {
|
||||
// match mut c.channel {
|
||||
// UIConsole { return c.channel.editor(args)! }
|
||||
// else { panic("can't find channel") }
|
||||
// }
|
||||
}
|
||||
22
lib/ui/generic/question.v
Normal file
22
lib/ui/generic/question.v
Normal file
@@ -0,0 +1,22 @@
|
||||
module generic
|
||||
|
||||
import freeflowuniverse.herolib.ui.console { UIConsole }
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel { QuestionArgs }
|
||||
|
||||
// args:
|
||||
//
|
||||
// - description string
|
||||
// - question string
|
||||
// - warning: string (if it goes wrong, which message to use)
|
||||
// - reset bool = true
|
||||
// - regex: to check what result need to be part of
|
||||
// - minlen: min nr of chars
|
||||
//
|
||||
pub fn (mut c UserInterface) ask_question(args QuestionArgs) !string {
|
||||
match mut c.channel {
|
||||
UIConsole { return c.channel.ask_question(args)! }
|
||||
// UITelegram { return c.ask_question(args) }
|
||||
else { panic("can't find channel") }
|
||||
}
|
||||
}
|
||||
19
lib/ui/generic/yesno.v
Normal file
19
lib/ui/generic/yesno.v
Normal file
@@ -0,0 +1,19 @@
|
||||
module generic
|
||||
|
||||
import freeflowuniverse.herolib.ui.console { UIConsole }
|
||||
// import freeflowuniverse.herolib.ui.telegram { UITelegram }
|
||||
import freeflowuniverse.herolib.ui.uimodel
|
||||
|
||||
// yes is true, no is false
|
||||
// args:
|
||||
// - description string
|
||||
// - question string
|
||||
// - warning string
|
||||
// - clear bool = true
|
||||
//
|
||||
pub fn (mut c UserInterface) ask_yesno(args uimodel.YesNoArgs) !bool {
|
||||
match mut c.channel {
|
||||
UIConsole { return c.channel.ask_yesno(args)! }
|
||||
else { panic("can't find channel") }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user