Giter Club home page Giter Club logo

toaster's Introduction

Toaster

Simulates an Android 'Toast' via modifier.

Supported Platforms

  • macOS 12+
  • iOS 14+

Default 'Toaster' Types

These types come with their own text and background colors but are customizable

public enum ToasterType { case warning, error, success, info }

Supported Positions

public enum ToasterPosition { case top, bottom }

Example

RPReplay_Final1665425251.mov

Usage

Info Toaster

struct MyView: View {

	@State private var isShowingToaster: Bool = false

	var body: some View {
		VStack {
		
		}
		.modifier(
			Toaster(
				isShowing: self.$isShowingToaster, 
				data: ToasterData(title: "My title", message: "My message", type: .success, position: .bottom)
			)
		)
	}
}

Custom Toaster

struct MyView: View {

	@State private var isShowingCustomToaster: Bool = false
	
	var body: some View {
		VStack {
		
		}
		.modifier(
			Toaster(
				isShowing: self.$isShowingCustomToaster,
				autoDismiss: false,
				enableBackgroundTapToDismiss: true,
				enableDragDetection: false,
				overlayBackgroundColor: .black.opacity(0.2),
				slideOverContent: { viewContext in
					AnyView(
						VStack {
							HStack {
								Spacer()
								
								Button(action: {
									withAnimation {
										self.isShowing.toggle()
									}
								}) {
									Image(systemName: "xmark")
										.imageScale(.medium)
										.foregroundColor(.white)
										.padding(10)
										.padding(.trailing, 20)
								}
							}
							
							Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
								.multilineTextAlignment(.center)
								.padding(.horizontal)
						}
						.clipShape(RoundedRectangle(cornerRadius: 10))
						.shadow(radius: 2)
						.padding(.top)
					)
				}
			)
		)
	}
}

SPM

Add 'Toaster' to your project by including the URL to this package - https://github.com/gfranks/Toaster

toaster's People

Contributors

gfranks avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

azuredark

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.