Initial version of demo MVVM app
Summary: For now, a static model with a simple CollectionView. The idea is to create a model that fetches some info from the web, like weather forecast, and show it to the user. Depends on D10300 Reviewers: SanghyeonLee, felipealmeida, cedric, bu5hm4n Reviewed By: SanghyeonLee Subscribers: brunobelo Differential Revision: https://phab.enlightenment.org/D10302
This commit is contained in:
parent
b8fd0c3b74
commit
b8f57276ef
|
@ -0,0 +1,10 @@
|
|||
project(
|
||||
'efl-example-mvvm', 'cs',
|
||||
version : '0.0.1',
|
||||
meson_version : '>= 0.49.0')
|
||||
|
||||
efl_mono = dependency('efl-mono', version : '>=1.23.99')
|
||||
efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
|
||||
|
||||
subdir('src')
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
src = files([
|
||||
'mvvm_basic.cs',
|
||||
])
|
||||
|
||||
deps = [efl_mono]
|
||||
|
||||
executable('efl_example_mvvm', src,
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
|
||||
class WeatherStation
|
||||
{
|
||||
public String Nick { get; set; }
|
||||
public float Temperature { get; set; }
|
||||
|
||||
public static Efl.UserModel<WeatherStation> CreateModel(Efl.Loop loop)
|
||||
{
|
||||
Efl.UserModel<WeatherStation> stations = new Efl.UserModel<WeatherStation>(loop);
|
||||
stations.Add (new WeatherStation{ Nick="FLN", Temperature=20 });
|
||||
stations.Add (new WeatherStation{ Nick="SAO", Temperature=25 });
|
||||
stations.Add (new WeatherStation{ Nick="RIO", Temperature=35 });
|
||||
stations.Add (new WeatherStation{ Nick="BSB", Temperature=30 });
|
||||
|
||||
return stations;
|
||||
}
|
||||
}
|
||||
|
||||
class WeatherServer
|
||||
{
|
||||
}
|
||||
|
||||
class Application : Efl.Csharp.Application
|
||||
{
|
||||
private Efl.Ui.Win win;
|
||||
|
||||
protected override void OnInitialize(string[] args)
|
||||
{
|
||||
win = new Efl.Ui.Win(parent: null, winName: "MVVM Example",
|
||||
winType: Efl.Ui.WinType.Basic);
|
||||
win.SetText("EFL Life");
|
||||
win.SetAutohide(true);
|
||||
|
||||
win.VisibilityChangedEvent += QuitEvt;
|
||||
|
||||
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(win);
|
||||
// Text property is temporarily excluded from the extension method generation
|
||||
// due to conflicts with the text classes.
|
||||
factory.BindProperty("text", "Nick");
|
||||
|
||||
var model = WeatherStation.CreateModel(Efl.App.AppMain);
|
||||
|
||||
var manager = new Efl.Ui.PositionManager.List(win);
|
||||
var list = new Efl.Ui.CollectionView(win);
|
||||
|
||||
list.PositionManager = manager;
|
||||
list.Model = model;
|
||||
list.Factory = factory;
|
||||
|
||||
win.SetContent(list);
|
||||
win.SetSize(new Eina.Size2D(640, 480));
|
||||
win.Visible = true;
|
||||
}
|
||||
|
||||
void QuitEvt(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
|
||||
{
|
||||
if (ev.arg == false)
|
||||
{
|
||||
Efl.App.AppMain.Quit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
var app = new Application();
|
||||
app.Launch();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue