-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpreadsheetApp.cs
More file actions
59 lines (51 loc) · 1.69 KB
/
Copy pathSpreadsheetApp.cs
File metadata and controls
59 lines (51 loc) · 1.69 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
using System.Linq;
using UnityEngine;
using UniMob.UI;
using UniMob.UI.Widgets;
using Samples.SimpleSpreadsheet.Domain;
using Samples.SimpleSpreadsheet.Presentation;
namespace Samples.SimpleSpreadsheet
{
public class SpreadsheetApp : UniMobUIApp
{
private readonly WidgetViewReference _cellView = WidgetViewReference.Resource("SpreadsheetCell");
private Spreadsheet _spreadsheet;
protected override void Initialize()
{
_spreadsheet = new Spreadsheet(Lifetime);
_spreadsheet.GetCell("A").Formula = "2";
_spreadsheet.GetCell("B").Formula = "3";
_spreadsheet.GetCell("C").Formula = "5";
_spreadsheet.GetCell("D").Formula = "A + B * C + 1";
StateProvider.Register<SpreadsheetCellWidget>(() => new SpreadsheetCellState(_cellView, _spreadsheet));
}
protected override Widget Build(BuildContext context)
{
return new Container
{
BackgroundColor = Color.white,
Size = WidgetSize.Stretched,
Child = BuildContent(),
};
}
private Widget BuildContent()
{
return new ScrollList
{
MainAxisAlignment = MainAxisAlignment.Center,
CrossAxisAlignment = CrossAxisAlignment.Center,
Children =
{
_spreadsheet.GetAllCellNames().Select(BuildCell)
}
};
}
private Widget BuildCell(string cellName)
{
return new SpreadsheetCellWidget(cellName)
{
Key = Key.Of(cellName)
};
}
}
}