Jamel  O'Reilly

Jamel O'Reilly

1659299040

UIDeviceComplete: UIDevice Extensions That Fill in The Missing Pieces

UIDeviceComplete

UIDevice extensions that fill in the missing pieces.

Whats this library about?

UIDeviceComplete is an iOS library intended to be a collection of extensions to UIDevice that provides functionality that UIDevice currently lacks like determining which iOS device you have (i.e iPhone X, iPhone 8, iPhone SE, iPad Pro, iPhone 7 etc) or determining the screen size of the device in inches.

Features

  •  Detect specific device like iPhone 7, iPhone SE or iPad Pro
  •  Get screen size of device in inches
  •  Get iOS Device family (iPod, iPhone or iPad)

Dont see a feature you need?

Feel free to open an Issue requesting the feature you want or send over a pull request!

Use

All of the extensions are called off of the dc variable which stands for ([UI]DeviceComplete) object that this library extends onto UIDevice that way native methods of UIDevice and methods of this library can easily be seen, also lowering the possibility of naming conflicts.

Getting common device name

UIDevice.current.dc.commonDeviceName // iPad Pro (12.9 inch, Wi-Fi+LTE)

Detecting iOS Device models

let device = UIDevice.current.dc.deviceModel

switch device {
    case .iPhoneX:
        print("So hows that iPhone X notch thing working out? Right...")
    case .iPhone6Plus, .iPhone7Plus:
        print("Lots of screen realestate eh?")
    case .iPhoneSE, .iPhone5, iPhone5S:
        print("Less iPhone is more iPhone...")
    case .iPadPro:
        print("Why?")
    default:
        print("Not sure what this is...")
}

Detecting iOS Device Screen Size (Inches)

Screen size can be be queried with the following computed property returning a simple Double that represents the screen size in inches:

let screenSize: Double = UIDevice.current.dc.screenSize.sizeInches

if screenSize <= 4.0 {
    print("Modest screen size; not so modest price tag")
} else if screenSize >= 5.5 {
    print("Plus is always a plus")
} else {
    print("Chances are this is an iPad or an iPhone (Texas Edition).")
}

Detecting iOS Device Family

If the type of device family is all you are after i.e iPhone or iPad and the specific model is not important then DeviceFamily might be what you need.

let deviceFamily = UIDevice.current.dc.deviceFamily

switch deviceFamily {
    case .iPhone:
        print("...phone home?")
    case .iPad:
        print("when it comes to screen size; more is more")
    case .iPod:
        print("Why not?")
    default:
        print("No family...")
}

Installation

Carthage

If you use Carthage to manage your dependencies, simply add UIDeviceComplete to your Cartfile:

github "Nirma/UIDeviceComplete"

If you use Carthage to build your dependencies, make sure you have added UIDeviceComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIDeviceComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add this line to your Podfile:

use_frameworks!
pod 'UIDeviceComplete'

Contributing to this project

Contributions are highly welcome

If there is something you wish to fix about the project, or wish to add any other kind of enhancements, propose to add to the project. Please feel free to send over a pull request or open an issue for this project.

Author: Nirma
Source Code: https://github.com/Nirma/UIDeviceComplete
License: MIT license

#ios #swift 

What is GEEK

Buddha Community

UIDeviceComplete: UIDevice Extensions That Fill in The Missing Pieces
Jamel  O'Reilly

Jamel O'Reilly

1659299040

UIDeviceComplete: UIDevice Extensions That Fill in The Missing Pieces

UIDeviceComplete

UIDevice extensions that fill in the missing pieces.

Whats this library about?

UIDeviceComplete is an iOS library intended to be a collection of extensions to UIDevice that provides functionality that UIDevice currently lacks like determining which iOS device you have (i.e iPhone X, iPhone 8, iPhone SE, iPad Pro, iPhone 7 etc) or determining the screen size of the device in inches.

Features

  •  Detect specific device like iPhone 7, iPhone SE or iPad Pro
  •  Get screen size of device in inches
  •  Get iOS Device family (iPod, iPhone or iPad)

Dont see a feature you need?

Feel free to open an Issue requesting the feature you want or send over a pull request!

Use

All of the extensions are called off of the dc variable which stands for ([UI]DeviceComplete) object that this library extends onto UIDevice that way native methods of UIDevice and methods of this library can easily be seen, also lowering the possibility of naming conflicts.

Getting common device name

UIDevice.current.dc.commonDeviceName // iPad Pro (12.9 inch, Wi-Fi+LTE)

Detecting iOS Device models

let device = UIDevice.current.dc.deviceModel

switch device {
    case .iPhoneX:
        print("So hows that iPhone X notch thing working out? Right...")
    case .iPhone6Plus, .iPhone7Plus:
        print("Lots of screen realestate eh?")
    case .iPhoneSE, .iPhone5, iPhone5S:
        print("Less iPhone is more iPhone...")
    case .iPadPro:
        print("Why?")
    default:
        print("Not sure what this is...")
}

Detecting iOS Device Screen Size (Inches)

Screen size can be be queried with the following computed property returning a simple Double that represents the screen size in inches:

let screenSize: Double = UIDevice.current.dc.screenSize.sizeInches

if screenSize <= 4.0 {
    print("Modest screen size; not so modest price tag")
} else if screenSize >= 5.5 {
    print("Plus is always a plus")
} else {
    print("Chances are this is an iPad or an iPhone (Texas Edition).")
}

Detecting iOS Device Family

If the type of device family is all you are after i.e iPhone or iPad and the specific model is not important then DeviceFamily might be what you need.

let deviceFamily = UIDevice.current.dc.deviceFamily

switch deviceFamily {
    case .iPhone:
        print("...phone home?")
    case .iPad:
        print("when it comes to screen size; more is more")
    case .iPod:
        print("Why not?")
    default:
        print("No family...")
}

Installation

Carthage

If you use Carthage to manage your dependencies, simply add UIDeviceComplete to your Cartfile:

github "Nirma/UIDeviceComplete"

If you use Carthage to build your dependencies, make sure you have added UIDeviceComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIDeviceComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add this line to your Podfile:

use_frameworks!
pod 'UIDeviceComplete'

Contributing to this project

Contributions are highly welcome

If there is something you wish to fix about the project, or wish to add any other kind of enhancements, propose to add to the project. Please feel free to send over a pull request or open an issue for this project.

Author: Nirma
Source Code: https://github.com/Nirma/UIDeviceComplete
License: MIT license

#ios #swift 

Jarvis  Maggio

Jarvis Maggio

1662130620

UIDeviceComplete: UIDevice Extensions That Fill in The Missing Pieces

UIDeviceComplete

UIDevice extensions that fill in the missing pieces.    

Whats this library about?

UIDeviceComplete is an iOS library intended to be a collection of extensions to UIDevice that provides functionality that UIDevice currently lacks like determining which iOS device you have (i.e iPhone X, iPhone 8, iPhone SE, iPad Pro, iPhone 7 etc) or determining the screen size of the device in inches.

Features

  •  Detect specific device like iPhone 7, iPhone SE or iPad Pro
  •  Get screen size of device in inches
  •  Get iOS Device family (iPod, iPhone or iPad)

Dont see a feature you need?

Feel free to open an Issue requesting the feature you want or send over a pull request!

Use

All of the extensions are called off of the dc variable which stands for ([UI]DeviceComplete) object that this library extends onto UIDevice that way native methods of UIDevice and methods of this library can easily be seen, also lowering the possibility of naming conflicts.

Getting common device name

UIDevice.current.dc.commonDeviceName // iPad Pro (12.9 inch, Wi-Fi+LTE)

Detecting iOS Device models

let device = UIDevice.current.dc.deviceModel

switch device {
    case .iPhoneX:
        print("So hows that iPhone X notch thing working out? Right...")
    case .iPhone6Plus, .iPhone7Plus:
        print("Lots of screen realestate eh?")
    case .iPhoneSE, .iPhone5, iPhone5S:
        print("Less iPhone is more iPhone...")
    case .iPadPro:
        print("Why?")
    default:
        print("Not sure what this is...")
}

Detecting iOS Device Screen Size (Inches)

Screen size can be be queried with the following computed property returning a simple Double that represents the screen size in inches:

let screenSize: Double = UIDevice.current.dc.screenSize.sizeInches

if screenSize <= 4.0 {
    print("Modest screen size; not so modest price tag")
} else if screenSize >= 5.5 {
    print("Plus is always a plus")
} else {
    print("Chances are this is an iPad or an iPhone (Texas Edition).")
}

Detecting iOS Device Family

If the type of device family is all you are after i.e iPhone or iPad and the specific model is not important then DeviceFamily might be what you need.

let deviceFamily = UIDevice.current.dc.deviceFamily

switch deviceFamily {
    case .iPhone:
        print("...phone home?")
    case .iPad:
        print("when it comes to screen size; more is more")
    case .iPod:
        print("Why not?")
    default:
        print("No family...")
}

Installation

Carthage

If you use Carthage to manage your dependencies, simply add UIDeviceComplete to your Cartfile:

github "Nirma/UIDeviceComplete"

If you use Carthage to build your dependencies, make sure you have added UIDeviceComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIDeviceComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add this line to your Podfile:

use_frameworks!
pod 'UIDeviceComplete'

Contributing to this project

Contributions are highly welcome

If there is something you wish to fix about the project, or wish to add any other kind of enhancements, propose to add to the project. Please feel free to send over a pull request or open an issue for this project.


Download Details:

Author: Nirma
Source code: https://github.com/Nirma/UIDeviceComplete

License: MIT license
#swift 

Creating Extensions for Visual Studio Code: A Complete Guide

Creating Extensions for Visual Studio Code: A Complete Guide

Extensions are an indispensable part of project development. They play a vital role in improving your productivity on a project, helping you customize your project, and more. Visual Studio Code extensions are add-ons that enhance your productivity and allow you to customize your project by adding new features or integrating existing tools into it. These extensions can customize existing or new projects by adding files, new palettes, menus, commands, and so on.

This post explains how to create a Visual Studio Code extension that creates a new project palette.

Let’s get started!

Prerequisites

Create a VSIX project

Follow these steps to create a VSIX project:

Step 1: Create a new VSIX project in Visual Studio Code through Terminal > New Terminal.

Step 2: Run the following command to install the Code Generator:

npm install -g yo generator-code

Now the extension is ready for use with a TypeScript or JavaScript project.

Step 3: Run the following generator command and wait for some time (approximately 5 minutes) for the extension generator to be loaded.

yo code

Step 4: Fill out all the fields for a TypeScript project as illustrated in the following screenshot.

Fill out all the fields for a TypeScript project

The extension project has been created successfully.

Step 5: Open the project by executing the following command:

cd Mycode //The Mycode is an extension identifier name.

code .

The project will be shown in the Explorer window as in the following screenshot.

Project shown in the Explorer window

Update the extension details

The package.json file has the VS Code extension name, description, author, license, and other details. Open the package.json file to edit the extension details as shown in the following screenshot.

Open the package.json file to edit the extension details

Create a Visual Studio Code project template

We can create a project template for any project type available in the dotnet new command. Here, I am going to create a new **Blazor **project for demonstration purposes.

Step 1: Create a new folder in the following structure.

{VSIX Project Location}/templates/BlazorServer

Step 2: Open the Terminal (Terminal > New Terminal) and navigate to the BlazorServer location using cd command.

Step 3: Run the following command to create the Blazor server app.

dotnet new blazorserver

The following screenshot shows the output on running the command.

output

#blazor #extensions #visual studio code #extensions #productivity #tech guide

rick william

1613729248

Custom Redirect Magento 2 Extension

**Custom Redirect Magento 2 Extension **

Redirect plays an important role for visitors and search engines in website development. Custom Redirect Magento 2 Extension
There is not any label or notification on the website that shows visitors to redirect them to a new location Sometimes you want to move your customer/customer group to go to some specific page or specific website.

#magento 2 custom redirect extension #custom redirect magento 2 extension #registration redirect magento 2 #magento 2 extension

Useful Swift Extension

After working with Swift for some time I found there are lot of things that aren’t there out of the box as with other languages. Following are some extensions that I think are useful for day to day working

Accessing string element by index

extension String {
    subscript(i:Int) ->Character {
        let index = self.index(self.startIndex, offsetBy: i)
        return self[index]
    }
}

#useful #development #swift #extension #swift-extensions