Skip to content

Instantly share code, notes, and snippets.

#!/Users/prafulla/miniconda2/bin/python
# path for python
# give exc permission
# -*- coding: utf-8 -*-
#to read cvs execell etc
import pandas
#get file from : https://drive.google.com/open?id=0B_P-kZ2NQv5aZWNSYUR2b2VrbFE
dataset = pandas.read_csv('50_Startups.csv')
class ViewController: UIViewController {
var userInterfaceStyle: UIUserInterfaceStyle?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
userInterfaceStyle = self.traitCollection.userInterfaceStyle
setupUI()
}
@prafullakumar
prafullakumar / BlurDemo.dart
Last active March 12, 2020 09:55
Dart: Blur effect
import 'dart:ui';
import 'package:flutter/material.dart';
class FrostedDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: Center (
child: Stack(
children: <Widget>[
@prafullakumar
prafullakumar / main.dart
Created April 12, 2020 06:56
show any kind of toast with example
import 'package:flutter/material.dart';
import 'toast.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Toast',
struct TextView: UIViewRepresentable {
//enum to define keyboard or input view handeling will be done in coorinator later
enum PickerType {
case keyboard(type: UIKeyboardType)
case datePicker(minDate: Date, maxDate: Date)
case customList(list: [String])
}
var pickerType: TextView.PickerType
final class Coordinator: NSObject {
var text: Binding<String>
var pickerType: TextView.PickerType
init(text: Binding<String>, pickerType: TextView.PickerType) {
self.pickerType = pickerType
self.text = text
}
@prafullakumar
prafullakumar / AdaptsKeyboard.swift
Created April 16, 2020 15:08
Demo - Keyboard Animation with Form SwiftUI
import SwiftUI
import Combine
struct KeyboardProperty {
var currentHeight: CGFloat = 0
var animationDuration: Double = 0
//keyboard notification also gives UIKeyboardAnimationCurveUserInfoKey using which we can completly sync keyboard animation with Scrollview move but In SwiftUI I cannot find any way to use the same.
}
class WebViewStateModel: ObservableObject {
@Published var pageTitle: String = "Web View"
@Published var loading: Bool = false
@Published var canGoBack: Bool = false
@Published var goBack: Bool = false
}
struct WebView: View {
enum NavigationAction {
case decidePolicy(WKNavigationAction, (WKNavigationActionPolicy) -> Void) //mendetory
struct ContentView: View {
@ObservedObject var webViewStateModel: WebViewStateModel = WebViewStateModel()
var body: some View {
NavigationView {
LoadingView(isShowing: .constant(webViewStateModel.loading)) { //loading logic taken from https://stackoverflow.com/a/56496896/9838937
//Add onNavigationAction if callback needed
WebView(url: URL.init(string: "https://www.google.com")!, webViewStateModel: self.webViewStateModel) // add
}
.navigationBarTitle(Text(webViewStateModel.pageTitle), displayMode: .inline)
final class WebViewWrapper : UIViewRepresentable {
...
final class Coordinator: NSObject {
@ObservedObject var webViewStateModel: WebViewStateModel
let action: ((_ navigationAction: WebView.NavigationAction) -> Void)?
init(action: ((_ navigationAction: WebView.NavigationAction) -> Void)?,
webViewStateModel: WebViewStateModel) {
self.action = action
self.webViewStateModel = webViewStateModel