This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Activity(Label = "Calculator", MainLauncher = true, Icon = "@mipmap/icon")] | |
public class MainActivity : Activity | |
{ | |
protected override void OnCreate(Bundle savedInstanceState) | |
{ | |
base.OnCreate(savedInstanceState); | |
SetContentView(Resource.Layout.Main); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeWebService : IWebService | |
{ | |
public int SleepDuration { get; set; } | |
public FakeWebService() | |
{ | |
SleepDuration = 1000; | |
} | |
private Task Sleep() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<User> Register(User user) | |
{ | |
await Sleep(); | |
return user; | |
} | |
public async Task<User[]> GetFriends(string userId) | |
{ | |
await Sleep(); | |
return new[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<Conversation[]> GetConversations( | |
string userName) | |
{ | |
await Sleep(); | |
return new[] | |
{ | |
new Conversation { Id = "1", UserName = "bobama" }, | |
new Conversation { Id = "2", UserName = "bobloblaw" }, | |
new Conversation { Id = "3", UserName = "georgemichael" }, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task AddFriend() | |
{ | |
if (settings.User == null) | |
throw new Exception("Not logged in."); | |
if (string.IsNullOrEmpty(UserName)) | |
throw new Exception("Username is blank."); | |
IsBusy = true; | |
try | |
{ | |
var friend = await service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TableSource : UITableViewSource | |
{ | |
const string MyCellName = "MyCell"; | |
const string TheirCellName = "TheirCell"; | |
readonly MessageViewModel messageViewModel = | |
ServiceContainer.Resolve<MessageViewModel>(); | |
readonly ISettings settings = ServiceContainer.Resolve<ISettings>(); | |
public override nint RowsInSection( | |
UITableView tableview, nint section) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly ConversationsController controller; | |
public TableSource(ConversationsController controller) | |
{ | |
this.controller = controller; | |
} | |
public override void RowSelected( | |
UITableView tableView, NSIndexPath indexPath) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//On Android in MainActivity.cs | |
Xamarin.Forms.Forms.Init(this, bundle); | |
//On iOS in AppDelegate.cs | |
Xamarin.Forms.Forms.Init(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SetUp] | |
public void SetUp() | |
{ | |
Xamarin.Forms.Mocks.MockForms.Init(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Dynamically load XAML | |
// NOTE: At the top, include using Xamarin.Forms.Xaml; | |
[Test] | |
public void LoadFromXaml() | |
{ | |
var label = new Label(); | |
label.LoadFromXaml("<Label Text=\"Woot\" />"); | |
Assert.AreEqual("Woot", label.Text); | |
} |