Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TextTutorial.Resources;
@coronarob
coronarob / activity_button.lua
Last active August 29, 2015 14:17
Button to trigger the activity panel
widget = require( "widget" )
shareButton = widget.newButton({
label = "Share",
onRelease = showShare,
})
shareButton.x = display.contentCenterX
shareButton.y = display.contentCenterY
@coronarob
coronarob / activity_call.lua
Last active August 29, 2015 14:17
Function to show the activity popup.
local shareButton -- will define later
local function showShare()
local popupName = "activity"
local isAvailable = native.canShowPopup( popupName )
local isSimulator = "simulator" == system.getInfo( "environment" )
-- If it is possible to show the popup
if isAvailable then
local listener = {}
@coronarob
coronarob / activity_items.lua
Last active August 29, 2015 14:17
List of items for the activity popup
local items =
{
{ type = "image", value = { filename = "Icon.png", baseDir = system.ResourceDirectory, } },
{ type = "string", value = "Hello, World" },
{ type = "url", value = "http://www.coronalabs.com" },
}
@coronarob
coronarob / build.settings
Last active August 29, 2015 14:17
Activity popup build.settings
settings =
{
plugins =
{
["CoronaProvider.native.popup.activity"] =
{
publisherId = "com.coronalabs",
supportedPlatforms = { iphone=true, ["iphone-sim"]=true },
},
},
@coronarob
coronarob / rateApp.cs
Last active August 29, 2015 14:17
Windows Phone 8 function to rate an App. Add this near the bottom of your MainPage class.
/// <summary>Called by Lua when it is requesting a login popup to be shown.</summary>
/// <param name="sender">The CoronaRuntimeEnvironment that dispatched this event.</param>
/// <param name="e">Provides the Lua vent table's fields/properties.</param>
/// <returns>Returns a boxed object to Lua.</returns>
private CoronaLabs.Corona.WinRT.ICoronaBoxedData rateApp(
CoronaLabs.Corona.WinRT.CoronaRuntimeEnvironment sender,
CoronaLabs.Corona.WinRT.CoronaLuaEventArgs e)
{
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
@coronarob
coronarob / rateapp_2.cs
Created March 24, 2015 00:32
Enable the rateApp Event
private void OnCoronaRuntimeLoaded(
object sender, CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs e)
{
// Keep a reference to the Corona runtime environment.
// It's needed so that your login window's results can be dispatched to Corona.
fCoronaRuntimeEnvironment = e.CoronaRuntimeEnvironment;
fCoronaRuntimeEnvironment.AddEventListener("rateApp", rateApp);
}
@coronarob
coronarob / generateEvent_3.lua
Last active August 29, 2015 14:17
Generate the event from Lua
local requestRateApp =
{
name = "rateApp",
}
Runtime:dispatchEvent(requestRateApp)
@coronarob
coronarob / gist:8387deec14650adf03a4
Created April 6, 2015 01:02
Position objects on a grid
local GRID_WIDTH = 8
local GRID_HEIGHT = 8
local CELL_WIDTH = 40
local CELL_HEIGHT = 40
--
-- Create a 2D array to hold our objects.
local grid = {}
for i = 1, GRID_HEIGHT do
grid[i] = {}
end
@coronarob
coronarob / main.lua
Last active August 29, 2015 14:19
Android Social Sharing example
if "simulator" == system.getInfo( "environment" ) then
native.showAlert( "Build for device", "This plugin is not supported on the Corona Simulator, please build for an iOS device or Xcode simulator", { "OK" } )
end
-- Require the widget library
local widget = require( "widget" )
-- Use the iOS 7 theme for this sample
widget.setTheme( "widget_theme_android_holo_dark" )