This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdaptableText extends StatelessWidget { | |
final String text; | |
final TextStyle style; | |
final TextAlign textAlign; | |
final TextDirection textDirection; | |
final double minimumFontScale; | |
final TextOverflow textOverflow; | |
const AdaptableText(this.text, | |
{this.style, | |
this.textAlign = TextAlign.left, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
struct Result: Identifiable { | |
var id = UUID() | |
var value: String | |
} | |
class RefreshableObject: ObservableObject { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import WebKit | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class WebViewWrapper : UIViewRepresentable { | |
@ObservedObject var webViewStateModel: WebViewStateModel //action two way binding | |
let action: ((_ navigationAction: WebView.NavigationAction) -> Void)? //delegates callback | |
let request: URLRequest | |
init(webViewStateModel: WebViewStateModel, | |
action: ((_ navigationAction: WebView.NavigationAction) -> Void)?, | |
request: URLRequest) { | |
self.action = action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() => runApp(MaterialApp( home: DemoApp())); | |
class DemoApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// newUI | |
// | |
// Created by prafull kumar on 3/4/20. | |
// Copyright © 2020 prafull kumar. All rights reserved. | |
// | |
import SwiftUI |