How to Build a Widget in Swift with WidgetKit

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • I teach you the basic concepts you'll need to know when building a Widget in Swift. We discuss the Widget timeline, snapshot and how they work. As well as design principles of a great widget. This video will get you up and running into the world of building awesome Widgets.
    This is a free preview of my WidgetKit course. This is only the first section that covers a basic widget. We get much more advanced in the full course with network calls, core data, configurations, lock screen widgets, live activities and dynamic island.
    Use code PREVIEW to get 15% off the complete course at
    seanallen.teachable.com/p/wid...
    .swift file to copy and paste MonthConfig from (as seen in video):
    www.dropbox.com/s/soafm5suahn...
    WWDC 2020 - Design Great Widgets:
    developer.apple.com/videos/pl...
    Human Interface Guidelines - Widget Section:
    developer.apple.com/design/hu...
    Twitter:
    / seanallen_dev
    Hired.com:
    hired.com/x/1n01g
    Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
    Paul Hudson's Hacking With Swift:
    gumroad.com/a/762098803
    Donny Wals - Combine:
    gumroad.com/a/909014131
    Mark Moeyken’s SwiftUI Books:
    www.bigmountainstudio.com/swiftui-views-book/fzc51
    Objc.io Books (Thinking in SwiftUI & Advanced Swift):
    gumroad.com/a/656585843
    Ray Wenderlich Books:
    store.raywenderlich.com/a/208...
    Links to my iOS Dev Setup & iOS Dev Book Recommendations
    www.amazon.com/shop/seanallen
    Timestamps:
    0:00 - What you will learn
    2:15 - What you need to know about Widgets
    5:11 - How to design great Widgets
    9:30 - Setting up our Xcode project
    12:12 - WidgetKit code explanation
    20:23 - Monthly Widget UI design & basic functionality
    36:00 - Dynamically change UI for each month
    49:07 - How to build on this
    #swift #softwaredeveloper #iosdeveloper
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 60

  • @seanallen
    @seanallen  ปีที่แล้ว +3

    Use code PREVIEW to get 15% off the WidgetKit Course at seanallen.teachable.com

    • @okjosh
      @okjosh ปีที่แล้ว

      Hi Sean, I notice in your link you mention that updated courses for iOS 16 will be out soon. For someone who just started learning, would you suggest waiting until those updates are live before investing the time to take your course? Or are there just minor changes from iOS15 -> 16 that the courses will be pretty much the same?

  • @naeem3dful
    @naeem3dful ปีที่แล้ว

    Thank you Sean Allen for this easy and clear and simple view for Widget

  • @nuriddinburkhonov5214
    @nuriddinburkhonov5214 10 หลายเดือนก่อน +1

    Thank you, very educational!

  • @FloWritesCode
    @FloWritesCode ปีที่แล้ว +2

    Great overview, Sean! I find your MonthConfig approach very interesting, personally I think I would have tried to solve that with an enum.

  • @apbrandom
    @apbrandom 6 หลายเดือนก่อน +3

    Great tutorial! Thank you very much, especially for copying and pasting it🔥

    • @seanallen
      @seanallen  6 หลายเดือนก่อน

      Glad you liked it and happy to help :)

  • @user-tw4ut5kl4z
    @user-tw4ut5kl4z ปีที่แล้ว +1

    Great tutorial, thanks a lot!

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad you liked it, Erop!

  • @dre5671
    @dre5671 ปีที่แล้ว +3

    Oh man! This preview is enticing me to get the course! I'm trying to hold off until I finish a project, But wanted you to know that this preview was a great idea!
    Thanks for giving us this handy knowledge Sean! So glad you're back at it with the videos!

    • @seanallen
      @seanallen  ปีที่แล้ว

      Thanks! Hope you enjoy this course. It was a lot of fun to make!

  • @arnoczkyzoltan6158
    @arnoczkyzoltan6158 10 หลายเดือนก่อน

    Thank You!

  • @elemento_arts
    @elemento_arts ปีที่แล้ว +1

    Great vid! although dates are tricky and probably overcomplicates things while learning Widgets. Simply Data, that's all we want for now 😅

  • @kalinbalabanov1013
    @kalinbalabanov1013 ปีที่แล้ว +1

    Really great stuff 🎉

    • @seanallen
      @seanallen  ปีที่แล้ว

      Glad you enjoyed it, Kalin!

  • @user-wh9om8je9t
    @user-wh9om8je9t 6 หลายเดือนก่อน

    @seanallen . Please make one video about the interactive widget

  • @nykse
    @nykse ปีที่แล้ว +2

    I made a counter app where the user can track anything they want to quit, such as smoking. What I want is, when the user starts the tracking process, they can see the progress on the home screen with a home widget. I can calculate the date difference, and there is no problem with that. However, I want to calculate the date difference every hour and refresh the home widget every hour. How can I do that?

  • @ArjunSingh-td5gw
    @ArjunSingh-td5gw ปีที่แล้ว +1

    The best video !!

  • @sebasyanni1258
    @sebasyanni1258 3 หลายเดือนก่อน

    If i have an api in my app folder.. how i can call the data? Is there any video to learn? Thank you, u are the best!

  • @JakeMarsh
    @JakeMarsh ปีที่แล้ว +1

    Thanks!

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      I appreciate the support, Jake! Hope you enjoy 😀

  • @ammarahmad9004
    @ammarahmad9004 ปีที่แล้ว +1

    Your reaction about how -3 works on code made me laugh, but it's still a good video about WidgetKit, thanks.

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Glad you enjoyed it, Ammar!

  • @robinandthedog
    @robinandthedog ปีที่แล้ว +1

    haha I got you typing capitals, just type vstack and it will complete to VStack, great tutorial by the way, I've build many widgets already, but still struggle to get a perfect adaptive design, the widgets differ so much in size over iPhone/iPad models, even using geometry reader...

  • @user-rd1lr4gd4q
    @user-rd1lr4gd4q หลายเดือนก่อน

    Amazing! I was having a hard time getting the initial colors you paste. the ones that were blocks in 'Color(*)'. Is there an easy way to get the desired colors other than the Xcode color library?
    Thanks again!!

  • @ulludots
    @ulludots ปีที่แล้ว

    I love the video but I met a problem where your code Text(entry.date.formatted(.dateTime.weekday())) does not exist. I am using Xcode 12.4 so please help me

  • @ilouran
    @ilouran ปีที่แล้ว

    do you know how to prevent opening app from widget ? I just wanna use backgorund callback, pls tell me if you have any idea

  • @gn0987123
    @gn0987123 ปีที่แล้ว

    How can i add custom button "action" on Widget ? 🧐

  • @md.tipusultan9629
    @md.tipusultan9629 ปีที่แล้ว

    Please help!
    How to add gif on a widget?

  • @rizwansayyed5043
    @rizwansayyed5043 ปีที่แล้ว

    Hey can please HELP MEE!!!!!
    I want to create a lock screen widget and i create it. But i just need one additional thing i want that when clicked on widget the widget should not open the app (Which it is opening). It should run certain that like making a call to the api.
    Can please any one help me how i can achieve this task i have searched all over the internet but didn't found any solution.
    PLEASE HELP MEE!!!!!

  • @ShredzZ
    @ShredzZ ปีที่แล้ว

    Hi, do you think iOS development is good path for full time freelancing? Lot of ppl saying best choice is web dev but I'm really enjoying swift. How is the job market?

    • @seanallen
      @seanallen  ปีที่แล้ว

      There are way more web dev jobs in the world than iOS dev. But... there are still plenty of iOS dev jobs and if that's what you enjoy, that's what I'd do.

  • @garylow-sy7pc
    @garylow-sy7pc ปีที่แล้ว +1

    0:47:52 You went to September because -3 means to go back 3 months from December, as 0 represents December last year. Since 12 - 3 = 9, the calculation gave you a date in September last year

    • @seanallen
      @seanallen  ปีที่แล้ว

      Good to know. Thanks for pointing that out!

  • @jawwaadsabree5573
    @jawwaadsabree5573 ปีที่แล้ว

    Are you working on a video for dynamic Island and live activities?

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Yes. That will release when they are officially launched in a later update to iOS 16 (likely in October). They are still in beta at the moment.

  • @mikeshafer
    @mikeshafer 6 หลายเดือนก่อน +1

    I just tried to follow your example but right in the beginning with the gradient, it doesn't fill the entire widget but just a square. How do I get this to fill the whole widget in iOS 17.2? I just signed up for the course, perhaps it covers that part. I definitely want to learn how to get dynamic data from a JSON endpoint.

    • @seanallen
      @seanallen  6 หลายเดือนก่อน

      Hey Mike, yes, this is covered in the course. iOS 17 introduced something called "contentMargins" that is causing that. We address this in the iOS 17 update section of each widget. (It's a pretty simple fix).

    • @tinypixel_
      @tinypixel_ 8 วันที่ผ่านมา

      Faced the same issue.
      In the MonthlyWidget section add `contentMarginsDisabled` at the end. That should fix it.
      .configurationDisplayName("My Widget")
      .description("This is an example widget.")
      .contentMarginsDisabled()

  • @muhammednadeem6339
    @muhammednadeem6339 ปีที่แล้ว

    Hi Sean, can we make the Widget translucent. I saw this implementated for whatspp medium size widgets

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      I've never done it, but I know it's possible. It has to do with pulling a screenshot of their wallpaper and matching the pixel area to be the background of the widget giving the illusion of transparency. I'm pretty sure that's how it's done, but like I said I've never done it.

  • @_Astr_
    @_Astr_ ปีที่แล้ว +2

    I have Xcode 12.5. Do I need Xcode 13+ for this course?

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      I believe Xcode 12.5 will be enough. Widgets were introduced in Xcode 12.

  • @glebdolskiy
    @glebdolskiy ปีที่แล้ว

    first tutorial which I saw a long intro 0_o

  • @tomlangendijk
    @tomlangendijk 7 หลายเดือนก่อน

    Can you create a widget carrying data from an app or site that is not yours?

    • @seanallen
      @seanallen  7 หลายเดือนก่อน +1

      Yes. If that app/site has an API you can make a network call to fetch the data and show it in your widget.

  • @lumaa_dev
    @lumaa_dev ปีที่แล้ว +1

    I didn’t remember it was that easy

    • @seanallen
      @seanallen  ปีที่แล้ว

      Keep in mind, that was the most basic example. They can get quite complex.

  • @paolooo15
    @paolooo15 ปีที่แล้ว +1

    Do you have IOS courses for beginners ?

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      Yup, you can find it at seanallen.teachable.com. I have one called iOS Dev Launchpad and another called SwiftUI Fundamentals.

    • @paolooo15
      @paolooo15 ปีที่แล้ว

      @@seanallen awesome I’m looking to start my journey for iOS dev ! Appreciate it !

    • @seanallen
      @seanallen  ปีที่แล้ว

      No problem. Happy to answer any questions you have about the courses!

  • @siempay
    @siempay ปีที่แล้ว +1

    You know its an INTRO when its 50 min long, thnks

    • @seanallen
      @seanallen  ปีที่แล้ว +2

      And this is only the small first section of a MUCH more in depth course 😀

    • @brudamonas8208
      @brudamonas8208 ปีที่แล้ว +1

      @@seanallen thanks for putting some of it for free

    • @seanallen
      @seanallen  ปีที่แล้ว +1

      No problem 😀

  • @martinpihooja7536
    @martinpihooja7536 ปีที่แล้ว +1

    0:42:25 There are two possibilities to change the file name.
    First and fastest, slow double click the file name and change it.
    Second option, look at the right, Inspectors view -> Identity and Type -> Name.
    Great tutorial and nice explanations.

  • @alphonsosensleyii7630
    @alphonsosensleyii7630 ปีที่แล้ว +1

    Thanks!

    • @seanallen
      @seanallen  ปีที่แล้ว

      Thanks for the support, Alphonso! I appreciate it 😀