Skip to content

Commit

Permalink
Comment out anonymous types.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Jul 28, 2015
1 parent 3b2fdff commit f7494e1
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 444 deletions.
44 changes: 22 additions & 22 deletions Wireclub.iOS/Account.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ type EditProfileViewController (handle:nativeint) as controller =
(fun _ -> controller.Birthday.BecomeFirstResponder() |> ignore),
(fun _ -> controller.Country.ResignFirstResponder() |> ignore)
)
let sourceCountry =
{
new UIPickerViewModel() with
override this.GetRowsInComponent(pickerView, comp) = nint countries.Length
override this.GetComponentCount(pickerView) = nint 1
override this.GetTitle(pickerView, row, comp) = countries.[int row].Name
override this.Selected(pickerView, row, comp) =
country <- Some countries.[int row]
controller.Country.Text <- country.Value.Name
}
// let sourceCountry =
// {
// new UIPickerViewModel() with
// override this.GetRowsInComponent(pickerView, comp) = nint countries.Length
// override this.GetComponentCount(pickerView) = nint 1
// override this.GetTitle(pickerView, row, comp) = countries.[int row].Name
// override this.Selected(pickerView, row, comp) =
// country <- Some countries.[int row]
// controller.Country.Text <- country.Value.Name
// }


let mutable region:LocationRegion option = None
Expand All @@ -113,16 +113,16 @@ type EditProfileViewController (handle:nativeint) as controller =
(fun _ -> controller.Country.BecomeFirstResponder() |> ignore),
(fun _ -> controller.Region.ResignFirstResponder() |> ignore)
)
let sourceRegion =
{
new UIPickerViewModel() with
override this.GetRowsInComponent(pickerView, comp) = nint regions.Length
override this.GetComponentCount(pickerView) = nint 1
override this.GetTitle(pickerView, row, comp) = regions.[int row].Name
override this.Selected(pickerView, row, comp) =
region <- Some regions.[int row]
controller.Region.Text <- region.Value.Name
}
// let sourceRegion =
// {
// new UIPickerViewModel() with
// override this.GetRowsInComponent(pickerView, comp) = nint regions.Length
// override this.GetComponentCount(pickerView) = nint 1
// override this.GetTitle(pickerView, row, comp) = regions.[int row].Name
// override this.Selected(pickerView, row, comp) =
// region <- Some regions.[int row]
// controller.Region.Text <- region.Value.Name
// }

let defaultDate = DateTime.UtcNow.AddYears(-100)

Expand Down Expand Up @@ -186,7 +186,7 @@ type EditProfileViewController (handle:nativeint) as controller =
// Country Picker
this.Country.InputView <- keyboardFrom pickerCountry.View accessoryCountry.View
this.Country.TintColor <- UIColor.Clear
pickerCountry.Picker.Model <- sourceCountry
// pickerCountry.Picker.Model <- sourceCountry
this.Country.EditingDidBegin.Add(fun _ ->
Async.startNetworkWithContinuation
(Settings.countries ())
Expand All @@ -211,7 +211,7 @@ type EditProfileViewController (handle:nativeint) as controller =
// Region Picker
this.Region.InputView <- keyboardFrom pickerRegion.View accessoryRegion.View
this.Region.TintColor <- UIColor.Clear
pickerRegion.Picker.Model <- sourceRegion
// pickerRegion.Picker.Model <- sourceRegion
this.Region.EditingDidBegin.Add(fun _ ->
match country with
| Some country ->
Expand Down
24 changes: 12 additions & 12 deletions Wireclub.iOS/AppDelegate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ type AppDelegate () =
let entryController = new EntryViewController()
let navigationController = new WireclubNavigationController(entryController)

let transactionObserver = {
new SKPaymentTransactionObserver() with
override this.UpdatedTransactions(queue, transactions) =
printfn "UpdatedTransactions"
for transaction in transactions do
if Api.userIdentity <> None then
Credits.postTransaction transaction
else
Credits.transactionsAdd transaction
}

// let transactionObserver = {
// new SKPaymentTransactionObserver() with
// override this.UpdatedTransactions(queue, transactions) =
// printfn "UpdatedTransactions"
// for transaction in transactions do
// if Api.userIdentity <> None then
// Credits.postTransaction transaction
// else
// Credits.transactionsAdd transaction
// }
//
let parsePushNotification (info:NSDictionary) =
match info.TryGetValue(NSObject.FromObject "aps") with
| true, null -> Unknown
Expand Down Expand Up @@ -99,7 +99,7 @@ type AppDelegate () =
)


SKPaymentQueue.DefaultQueue.AddTransactionObserver(transactionObserver)
// SKPaymentQueue.DefaultQueue.AddTransactionObserver(transactionObserver)

window.RootViewController <- navigationController
window.MakeKeyAndVisible ()
Expand Down
94 changes: 47 additions & 47 deletions Wireclub.iOS/Chat.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,35 @@ type ChatRoomUsersViewController (users:UserProfile[]) =

let users = users.OrderBy(fun e -> e.Name).ToArray()

let source = {
new UITableViewSource() with
override this.GetCell(tableView, indexPath) =
let user = users.[indexPath.Row]
let cell =
match tableView.DequeueReusableCell "room-user-cell" with
| null -> new UITableViewCell (UITableViewCellStyle.Subtitle, "room-user-cell")
| c -> c

cell.Tag <- nint indexPath.Row
cell.TextLabel.Text <- user.Name
Image.loadImageForCell (App.imageUrl user.Avatar 100) Image.placeholder cell tableView
cell

override this.RowsInSection(tableView, section) =
nint users.Length

override this.RowSelected(tableView, indexPath) =
tableView.DeselectRow (indexPath, false)
let user = users.[indexPath.Row]
Navigation.navigate ("/users/" + user.Slug) (Some { Id = user.Id; Label = user.Name; Slug = user.Slug; Image = user.Avatar })
()
}

// let source = {
// new UITableViewSource() with
// override this.GetCell(tableView, indexPath) =
// let user = users.[indexPath.Row]
// let cell =
// match tableView.DequeueReusableCell "room-user-cell" with
// | null -> new UITableViewCell (UITableViewCellStyle.Subtitle, "room-user-cell")
// | c -> c
//
// cell.Tag <- nint indexPath.Row
// cell.TextLabel.Text <- user.Name
// Image.loadImageForCell (App.imageUrl user.Avatar 100) Image.placeholder cell tableView
// cell
//
// override this.RowsInSection(tableView, section) =
// nint users.Length
//
// override this.RowSelected(tableView, indexPath) =
// tableView.DeselectRow (indexPath, false)
// let user = users.[indexPath.Row]
// Navigation.navigate ("/users/" + user.Slug) (Some { Id = user.Id; Label = user.Name; Slug = user.Slug; Image = user.Avatar })
// ()
// }
//
[<Outlet>]
member val Table: UITableView = null with get, set

override controller.ViewDidLoad () =
controller.Table.Source <- source
// controller.Table.Source <- source
controller.Table.ReloadData ()
()

Expand Down Expand Up @@ -375,27 +375,27 @@ type ChatRoomViewController (room:Entity) as controller =
| error -> controller.HandleApiFailure error)


member val WebViewDelegate = {
new UIWebViewDelegate() with
override this.ShouldStartLoad (view, request, navigationType) =
let uri = new Uri(request.Url.AbsoluteString)
match uri.Segments with
| [|_; "template" |] -> true
| [|_; "users/"; slug |] ->
match users.Values |> Seq.tryFind (fun (user, _) -> user.Slug = slug) with
| Some (user, _) -> Navigation.navigate (sprintf "/users/%s" slug) (Some { Id = user.Id; Label = user.Name; Slug = user.Slug; Image = user.Avatar })
| _ -> Navigation.navigate (sprintf "/users/%s" slug) None
false
| _ ->
Navigation.navigate (uri.ToString()) None
false

override this.LoadFailed (view, error) =
showSimpleAlert "Error" error.Description "Close"

override this.LoadingFinished (view) =
load ()
}
// member val WebViewDelegate = {
// new UIWebViewDelegate() with
// override this.ShouldStartLoad (view, request, navigationType) =
// let uri = new Uri(request.Url.AbsoluteString)
// match uri.Segments with
// | [|_; "template" |] -> true
// | [|_; "users/"; slug |] ->
// match users.Values |> Seq.tryFind (fun (user, _) -> user.Slug = slug) with
// | Some (user, _) -> Navigation.navigate (sprintf "/users/%s" slug) (Some { Id = user.Id; Label = user.Name; Slug = user.Slug; Image = user.Avatar })
// | _ -> Navigation.navigate (sprintf "/users/%s" slug) None
// false
// | _ ->
// Navigation.navigate (uri.ToString()) None
// false
//
// override this.LoadFailed (view, error) =
// showSimpleAlert "Error" error.Description "Close"
//
// override this.LoadingFinished (view) =
// load ()
// }

member this.UserButton:UIBarButtonItem =
new UIBarButtonItem(UIImage.FromFile "UIButtonBarProfile.png", UIBarButtonItemStyle.Plain, new EventHandler(fun (s:obj) (e:EventArgs) ->
Expand Down Expand Up @@ -455,7 +455,7 @@ type ChatRoomViewController (room:Entity) as controller =

override this.ViewDidLoad () =
this.WebView.BackgroundColor <- UIColor.White
this.WebView.Delegate <- this.WebViewDelegate
// this.WebView.Delegate <- this.WebViewDelegate

this.NavigationItem.Title <- room.Label
this.NavigationItem.LeftItemsSupplementBackButton <- true
Expand Down
130 changes: 65 additions & 65 deletions Wireclub.iOS/Credits.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,62 +105,62 @@ type CreditsViewController () as controller =
formatter.StringFromNumber(product.Price)

let font = UIFont.SystemFontOfSize UIFont.ButtonFontSize
let source = {
new UITableViewSource() with

override this.GetCell(tableView, indexPath) =
let (id, name, desc, price, product, bundle) = products.[indexPath.Row]
let cell =
match tableView.DequeueReusableCell "credits-product-cell" with
| null -> new UITableViewCell (UITableViewCellStyle.Subtitle, "credits-product-cell")
| c -> c

cell.Tag <- nint indexPath.Row
cell.TextLabel.Text <- name
cell.DetailTextLabel.Text <- desc

let size = (new NSString(price)).StringSize(font)
cell.AccessoryView <- new UILabel(new CGRect(nfloat 0.f, nfloat 0.f, size.Width, size.Height), Text = price, Font = font)
cell.ImageView.Image <- UIImage.FromFile(String.Format( "purchase-{0}.png", (int bundle.Price)))
cell

override this.RowsInSection(tableView, section) = nint products.Length

override this.RowSelected(tableView, indexPath) =
tableView.DeselectRow (indexPath, false)
let (id, name, desc, price, product, bundle) = products.[indexPath.Row]

let payment = SKMutablePayment.PaymentWithProduct product
payment.Quantity <- nint 1
SKPaymentQueue.DefaultQueue.AddPayment(payment)
}

let products = {
new SKProductsRequestDelegate () with
override this.ReceivedResponse (request, response) =
products <-
[
for product in response.Products do
match bundles |> Seq.tryFind(fun p -> p.AppStoreId = product.ProductIdentifier) with
| Some bundle ->
yield (
product.ProductIdentifier,
product.LocalizedTitle,
product.LocalizedDescription,
(localizedPrice product),
product,
bundle
)
| _ -> ()
] |> List.sortBy(fun (_, _, _, _, _, bundle) -> bundle.RegularCredits)

for product in response.InvalidProducts do
Logger.log (Exception(String.Format("[StoreKit] InvalidProduct - {0}", product)))

controller.Table.ReloadData()

override this.RequestFailed (request, error) = Logger.log (Exception( error.Description))
}
// let source = {
// new UITableViewSource() with
//
// override this.GetCell(tableView, indexPath) =
// let (id, name, desc, price, product, bundle) = products.[indexPath.Row]
// let cell =
// match tableView.DequeueReusableCell "credits-product-cell" with
// | null -> new UITableViewCell (UITableViewCellStyle.Subtitle, "credits-product-cell")
// | c -> c
//
// cell.Tag <- nint indexPath.Row
// cell.TextLabel.Text <- name
// cell.DetailTextLabel.Text <- desc
//
// let size = (new NSString(price)).StringSize(font)
// cell.AccessoryView <- new UILabel(new CGRect(nfloat 0.f, nfloat 0.f, size.Width, size.Height), Text = price, Font = font)
// cell.ImageView.Image <- UIImage.FromFile(String.Format( "purchase-{0}.png", (int bundle.Price)))
// cell
//
// override this.RowsInSection(tableView, section) = nint products.Length
//
// override this.RowSelected(tableView, indexPath) =
// tableView.DeselectRow (indexPath, false)
// let (id, name, desc, price, product, bundle) = products.[indexPath.Row]
//
// let payment = SKMutablePayment.PaymentWithProduct product
// payment.Quantity <- nint 1
// SKPaymentQueue.DefaultQueue.AddPayment(payment)
// }
//
// let products = {
// new SKProductsRequestDelegate () with
// override this.ReceivedResponse (request, response) =
// products <-
// [
// for product in response.Products do
// match bundles |> Seq.tryFind(fun p -> p.AppStoreId = product.ProductIdentifier) with
// | Some bundle ->
// yield (
// product.ProductIdentifier,
// product.LocalizedTitle,
// product.LocalizedDescription,
// (localizedPrice product),
// product,
// bundle
// )
// | _ -> ()
// ] |> List.sortBy(fun (_, _, _, _, _, bundle) -> bundle.RegularCredits)
//
// for product in response.InvalidProducts do
// Logger.log (Exception(String.Format("[StoreKit] InvalidProduct - {0}", product)))
//
// controller.Table.ReloadData()
//
// override this.RequestFailed (request, error) = Logger.log (Exception( error.Description))
// }

let mutable appEventObserver:NSObject = null

Expand All @@ -179,7 +179,7 @@ type CreditsViewController () as controller =
member val Table: UITableView = null with get, set

override this.ViewDidLoad () =
this.Table.Source <- source
// this.Table.Source <- source
appEventObserver <- NSNotificationCenter.DefaultCenter.AddObserver(NSString.op_Explicit "Wireclub.AppEvent", (fun n -> this.OnAppEvent n))

Async.startNetworkWithContinuation
Expand All @@ -188,14 +188,14 @@ type CreditsViewController () as controller =
| Api.ApiOk result ->
this.SetBalance (result.Credits)
bundles <- result.Bundles
let ids =
[
for bundle in bundles do
yield bundle.AppStoreId
]

let request = new SKProductsRequest(NSSet.MakeNSObjectSet<NSString>(ids.Select(fun s -> new NSString(s)).ToArray()), Delegate = products)
request.Start()
// let ids =
// [
// for bundle in bundles do
// yield bundle.AppStoreId
// ]
//
// let request = new SKProductsRequest(NSSet.MakeNSObjectSet<NSString>(ids.Select(fun s -> new NSString(s)).ToArray()), Delegate = products)
// request.Start()
| error -> this.HandleApiFailure error
)

Expand Down
Loading

0 comments on commit f7494e1

Please sign in to comment.