Skip to content

Instantly share code, notes, and snippets.

View sjehutch's full-sized avatar

scott hutchinson sjehutch

View GitHub Profile
@sjehutch
sjehutch / gist:4defbdb2123ed899cad91e4b29ff65c8
Created November 26, 2017 13:36
Swift 3 move keyboard up textfield
func animateTextField(textField: UITextField, up: Bool)
{
let movementDistance:CGFloat = -130
let movementDuration: Double = 0.3
var movement:CGFloat = 0
if up
{
movement = movementDistance
}
@sjehutch
sjehutch / show hide.cs
Last active December 5, 2017 01:33
Show Hide Password Field xamarin IOS
bool showPassClick;
this.showPassClick = true;
partial void BtnShowPassword_TouchUpInside(UIButton sender)
{
if (showPassClick == true)
{
txtPassword.SecureTextEntry = false;
showPassClick = false;
@sjehutch
sjehutch / saveuser.cs
Created December 5, 2017 20:29
save username checkbox xamarin iOS font awesome
bool saveUserClick;
this.saveUserClick = true;
partial void BtnSaveUsername_TouchUpInside(UIButton sender)
{
if (saveUserClick == true)
{
saveUserClick = false;
btnSaveUsername.SetTitle("Save Username ", UIControlState.Normal);
@sjehutch
sjehutch / user defaults.cs
Created December 11, 2017 05:01
Saving fields to nsuserdefaults xamarin
NSUserDefaults userdefaults = NSUserDefaults.StandardUserDefaults;
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
this.txtUserName.Text = NSUserDefaults.StandardUserDefaults.StringForKey("username");
this.txtPassword.Text = NSUserDefaults.StandardUserDefaults.StringForKey("password");
}
NSUserDefaults.StandardUserDefaults.SetString(credentials.username.ToString(), "username");
@sjehutch
sjehutch / show hide.cs
Created December 14, 2017 21:14
showhideview table cell xamarin ios
partial void btn_expand(UIButton sender)
{
stkSummary.Hidden = !stkSummary.Hidden;
if (stkSummary.Hidden) {
btnExpand.SetImage(UIImage.FromBundle("Dashboard_Plus_Button"), UIControlState.Normal);
}
else if (!stkSummary.Hidden){
btnExpand.SetImage(UIImage.FromBundle("Dashboard_Minus_Button"), UIControlState.Normal);
@sjehutch
sjehutch / awaitasync.cs
Created December 17, 2017 21:17
async await c#
Console.WriteLine(DateTime.Now);
// This block takes 1 second to run because all
// 5 tasks are running simultaneously
{
var a = Task.Delay(1000);
var b = Task.Delay(1000);
var c = Task.Delay(1000);
var d = Task.Delay(1000);
var e = Task.Delay(1000);
@sjehutch
sjehutch / customnavtext.cs
Last active December 19, 2017 20:56
Customize your navigation items text Xamarin IOS
//Mark: Add into your appdelegate In the FinishedLaunching method
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
var attr = UINavigationBar.Appearance.GetTitleTextAttributes();
attr.Font = UIFont.SystemFontOfSize(14f, weight: UIFontWeight.Bold);
UINavigationBar.Appearance.SetTitleTextAttributes(attr);
}
@sjehutch
sjehutch / validate.swift
Created January 2, 2018 10:16
validate email method swift
func isValidEmail(testStr:String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: testStr)
}
isValidEmail(testStr: "sjehutchmail.com")
@sjehutch
sjehutch / animate.cs
Created January 3, 2018 16:31
animation xamarin background color
UIView.Animate(0.25,
animation: () => {
this.testView.BackgroundColor = new UIColor(red: 0.18f, green: 0.60f, blue: 0.95f, alpha: 1.0f);
},
completion: () => {
this.testView.BackgroundColor = new UIColor(red: 0.08f, green: 0.38f, blue: 0.80f, alpha: 1.0f);
}
);
@sjehutch
sjehutch / GradientView.swift
Last active January 4, 2018 19:41
GradientBackgroundView-Class
import Foundation
import UIKit
class GradientView: UIView {
override open class var layerClass: AnyClass {
return CAGradientLayer.classForCoder()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)