Code Monkey home page Code Monkey logo

drops's Introduction

Hi there 👋

I'm a software engineer and the creator of the open source projects below 👇

I currently work at Booking.com, previously Spotify, Backbase, and others.

I love building iOS frameworks and apps, web APIs and contributing to open source projects. Swift is my favored tool, but I also enjoy working with other languages like Python, Ruby, and Javascript.

On the side, I enjoy practicing Arabic calligraphy, playing the piano, and looking for the best cup of espresso in town.

You can find me online on Linkedin.

drops's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drops's Issues

How to apply dark mode?

How do I apply dark mode? I can't find it in the documentation, but I see it's listed as a feature.

Unable to see large text

When subtitle is long text the text size is too small that it is unable to be seen, when text is large drop size should be increased instead of decreasing the font size please check this.
uploadingImage

UI Configuration

It would be nice to be able to change Drop UI. Like background color, text color, text size, ...
Do you plan to add this feature?

Customisation

Hello and thank you for creating this!
Is it possible for further customisation? Eg. using it for error messages (think on having a red background color etc)

DropView.swift - RoundImageView - Can lead to cropping with some icons

Hi,

Seems like the drop can crop some large icons. For example square.on.square, leads to the most distant corners to be cut off, showing a circular mask.

Simulator Screen Shot - iPhone 14 Pro - 2023-04-04 at 17 27 06

At first sight seems like the problem is at DropView.swift imageView as it uses RoundImageView.

There are two situations where the RoundImageView is detrimental and good:

  1. Icon (without background). If it doesn't have any background, the icon shouldn't be rounded, as can crop part of it.
  2. Image (with background). If the users passes an image there, the icon should be rounded as this would preserve the system styling.

Both cases might cause problems to one another if solved. I believe the first one should be prioritised, as the user can round any UIImage passed to the Drop. But this could cause a whole lot of problems to a lot of people that are currently using custom images with background. But, as I read on other issues the philosophy of this repo is to mimic what Apple does, and such all icons should not have a background anyway. The user can always pass a custom rounded UIImage...

Another solution could be create a new constructor for the Drop with a roundIcon: Bool = false, supporting all use cases.

Let me know your thoughts on this.

Amazing library bwt!

Edited: I misunderstood the usage of RoundImageView, is not used on the button. + I understood why is rounded.

Dark/Light mode control

I prefer to have overlays like this show in the opposite color scheme than the current one in use - this is to make sure it stands out against the background of the normal app views. So, feature request!

Possible issue with "drop" not being dismissed after navigating away from View Controller

Hello,

I just implemented Drops yesterday in my mostly UIKit app and while testing it, I managed to have "drop" stay visible permanently.

I initialized the Drops in my view controller as per the docs:

class ViewController: UIViewController {
    let drops = Drops(delayBetweenDrops: 1.0)

And then while drop was shown, I navigated away from the view controller and the drop would stay visible until I force quit the app. Even trying to show new drop wouldn't dismiss this old one.

It seems to me that by navigating away, the drops instance would be deallocated and therefore unable to remove the existing drop.

For now I solved it by calling drops.hideAll() in the viewDidDisappear.

So I am curious whether this is indeed an bug or just incorrect usage on my part and I should keep the Drops instance outside the view controllers to ensure its continuous lifespan.

Thanks!

Suppor fo Localized String

Now works fine, problems with cache simulator

I have Localized catalog string
fields_need_completed = se requiere rellenar todos los campos

I Try with (not work)

Drops.show(Drop(title: String(localized: "fields_need_completed"), icon: UIImage(systemName: "exclamationmark.triangle.fill")))

macOS support in SwiftUI

I was under the impression this library was supported on macOS, however now that I look closely I see only UIKit mentioned, not AppKit.

So when you talk about SwiftUI support on macOS, do you only mean mac Catalyst, or what about native macOS support via SwiftUI?

When I try to build on macOS in my SwiftUi multi-platform app I get error "cannot find Drop in scope" am I doing something wrong or is this not supported?

Xcode 13: 'shared' is unavailable in application extensions for iOS

Due to a change in the latest Xcode beta, this no longer compiles as a SwiftPM dependency, even for a target that is not an extension.
https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/8

It appears @available(iOSApplicationExtension, unavailable) now needs to be added in WindowViewController:44.

Error

SourcePackages/checkouts/Drops/Sources/WindowViewController.swift:44:45: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

Present `Drop`s "everywhere"

Hey @omaralbeik,

is there any plan atm for supporting presenting DropViews at any level of the view hierarchy?
I feel like it would make a lot of sense to decouple the actual presentation from the all WindowViewController "magic", especially for a better SwiftUI support, as it would allow to use Drops in a declarative way.

/// An optional `Drop` binding.
@State var drop: Drop?

// Something along the lines of…
var body: some View {
   Text("A random text")
      .frame(maxWidth: .infinity, maxHeight: .infinity)
      .drop($drop)
}

With a definition allowing for a Drops parameter, so that it could still reuse the same code, or even better, imho, just considering delayBetweenDrops (as the whole Binding thing would most likely deprecate the current queue system), or nothing at all (letting SwiftUI animation deal with that).

public extension View {
   /// Present a `Drop` view.
   ///
   /// - parameters:
   ///   - drop: An optional `Drop` binding. 
   ///   - drops: Some valid `Drops`. Defaults to `.shared`.
   /// - returns: Some `View`.
   drop(_ drop: Binding<Drop?>, with drops: Drops = .shared) -> some View {
      []
   }

   // … OR …

   /// Present a `Drop` view.
   ///
   /// - parameters:
   ///   - drop: An optional `Drop` binding. 
   ///   - delayBetweenDrops: Some valid `TimeInterval`. Defaults to `0.5`.
   /// - returns: Some `View`.
   drop(_ drop: Binding<Drop?>, delayedBy delayBetweenDrops: TimeInterval = 0.5) -> some View {
      []
   }
}

Of course this would require Drop to at least conform to Identifiable (either directly — unlikely due to the current deployment target, or just as an analogy), which would also give the user the ability to cancel any queued presenter "for free", using the imperative Drops (when dealing with UIKit directly).

/// Hide some drops.
/// - Parameter drops: `Drop`s to hide.
/// - Note: 
///    This is really just some "concept code". 
///    I tried to make it efficient instead of concise, 
///    but it's very much a draft.
public func hide<C: Collection>(_ drops: C) where C.Element == Drop {
    var identifiers = Set(drops.map(\.id))
    var shouldHideCurrent = false
    dispatchQueue.sync {
        queue.removeAll {
            let isRemoving = identifiers.remove($0.drop.id) != nil
            if !shouldHideCurrent { shouldHideCurrent = isRemoving && current?.drop.id == $0.drop.id }
            return isRemoving
        }
        guard shouldHideCurrent else { return }
        hideCurrent()
    }
}

Retain-Cycle in `WindowViewController`

In Presenter we have this:

init(toast: Toast, delegate: AnimatorDelegate) {
    self.toast = toast
    self.view = ToastView.initialize(for: toast)
    self.viewController = .init(value: WindowViewController())
    self.animator = Animator(position: toast.position, delegate: delegate)
    self.context = AnimationContext(view: view, container: maskingView)
}

and viewController is Weak<WindowViewController>.
So using self.viewController = .init(value: WindowViewController()), object related to WindowViewController() SHOULD release from memory immediately, because it declared weak and there is no strong-referece to it, but it will not. Why? Because of this:

final class WindowViewController: UIViewController {
	
    var window: UIWindow?
    
    // ...
	
    init() {
        let view = PassthroughView()
        let window = PassthroughWindow(hitTestView: view)
        self.window = window
        super.init(nibName: nil, bundle: nil)
        self.view = view
        window.rootViewController = self
    }

    // ...	
}

This init is creating Retain-Cycle, because WindowViewController has a strong-reference to window, and window has a strong-reference to WindowViewController by window.rootViewController = self.

So I think whenever we present a Toase, we are creating a UIWindow that will never be released.

iOS 10 support

Hi would it be possible to lower min iOS target to iOS10 ?
Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.