<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jeff McMorris on Medium]]></title>
        <description><![CDATA[Stories by Jeff McMorris on Medium]]></description>
        <link>https://medium.com/@jeffmcmorris?source=rss-3a79afe75f66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Gk_iXz-7mDXggxtk.jpg</url>
            <title>Stories by Jeff McMorris on Medium</title>
            <link>https://medium.com/@jeffmcmorris?source=rss-3a79afe75f66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:41:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jeffmcmorris/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dart code to playback AtmosFX videos to three separate screens.]]></title>
            <link>https://jeffmcmorris.medium.com/dart-code-to-playback-atmosfx-videos-to-three-separate-screens-5142b820987a?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/5142b820987a</guid>
            <category><![CDATA[atmosfx]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[haunted-house]]></category>
            <category><![CDATA[halloween]]></category>
            <category><![CDATA[video-playback]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Thu, 01 Aug 2024 01:48:55 GMT</pubDate>
            <atom:updated>2024-08-01T02:09:51.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*dQggyRkBji0bKUhCCYdtvQ@2x.png" /><figcaption>AtomsFX Unliving Portraits</figcaption></figure><p>I needed a way to playback <a href="https://atmosfx.com/collections/halloween/products/unliving-portraits">AtmosFX videos</a> on three separate screens and stay in sync. Initially I tried using three media players, one per screen and then starting them all together. The problem with this method is they would eventually lose sync. I figured the only way for them to stay in sync would be for one device to control the playback of all video files.</p><p>I wrote a small command line program in dart which launches each video file to a separate screen in full screen mode and then loops the video when it reaches the end. This solves the video syncing issue for my use case. The only thing you need is a computer with the ability to playback 1080p videos to three separate monitors.</p><p>Below is the relevant code:</p><pre>import &#39;dart:io&#39;;<br><br>String myVideoPath = &#39;videos/&#39;;<br>void main() async {<br>  // Function to play a video in a separate window using mpv video player<br>  void playVideo(String videoPath, int screen) {<br>    print(&#39;Playing video: $videoPath on screen: $screen&#39;);<br>    Process.run(<br>        &#39;mpv&#39;, [&#39;-fs&#39;, &#39;--screen=$screen&#39;, &#39;--loop-file=inf&#39;, videoPath]);<br>  }<br><br>  playVideo(&#39;$myVideoPath/Gent.mp4&#39;, 0);<br>  playVideo(&#39;$myVideoPath/Madam.mp4&#39;, 1);<br>  playVideo(&#39;$myVideoPath/Daughter.mp4&#39;, 2);<br>}</pre><p>The code uses the free, open source, and cross-platform <a href="https://mpv.io/">mpv media player</a>. You will also need to <a href="https://docs.flutter.dev/get-started/install">install dart and/or flutter</a> to run the program. You can see more about running command line apps with this <a href="https://dart.dev/tools/dart-tool">link</a>. You should be able to run this code cross platform (windows, mac, linux, etc.).</p><p>I was using the video files from the <a href="https://atmosfx.com/collections/halloween/products/unliving-portraits">Unliving Portrait Collection from Atmosfx</a>. I merged the ones in family feud singles directory TV/Wall no frame. There are three different scenes so I used imovie to merge each of the Daughter scenes into one video and then did the same for the Gent and the Madam. It then just plays an infinite loop of the three videos, one video per monitor. I did not include the actual videos. They are available for purchase from atmosFx. I am not affiliated with them I just wanted a way to easily play the videos on 3 separate monitors so I could make three framed monitors and keep all the videos in sync. You need a computer that can support output to three separate monitors.</p><p>Here is the git repository where you can download the code.</p><p><a href="https://github.com/delay/atmosfx_video_player">GitHub - delay/atmosfx_video_player</a></p><p>To run the app, place your video files in the videos folder and name them Gent.mp4, Madam.mp4, Daughter.mp4. If you change the name or video format you will need to edit the /bin/atmosfx_video_player.dart file with the new names. You can also change the monitor order by changing the 0,1,2 after each video name. In order to run the app you need to cd into the project directory from the command line and type ‘dart run’.</p><pre>cd atmosfx_video_player<br>dart run</pre><p>Well hopefully someone will find this <a href="https://github.com/delay/atmosfx_video_player">code</a> useful. Feel free to use it however you like (MIT license).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5142b820987a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sveltekit Auth with shadcn-svelte and lucia.]]></title>
            <link>https://jeffmcmorris.medium.com/sveltekit-auth-with-shadcn-svelte-and-lucia-1923a8217bec?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/1923a8217bec</guid>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 19:36:59 GMT</pubDate>
            <atom:updated>2024-02-23T00:47:50.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PLPDbBAPEh9-HffR" /><figcaption>Sveltekit Auth with lucia and shadcn-svelte</figcaption></figure><p>I created a new Sveltekit Auth Project. An example website is currently deployed <a href="https://sveltekit-auth-alpha.vercel.app/">here</a>. It is an open source auth starter project utilizing <a href="https://lucia-auth.com/">Lucia</a> for authentication, <a href="https://www.shadcn-svelte.com/">shadcn-svelte</a> for ui elements, <a href="https://lucide.dev/">Lucide</a> for icons, <a href="https://www.prisma.io/">Prisma</a> for database connectivity and type safety and <a href="https://kit.svelte.dev/">Sveltekit</a> for the javascript framework. I also used <a href="https://zod.dev/">Zod</a> and <a href="https://superforms.vercel.app/">Superforms</a> to handle form validation and management. It has email verification, password reset, and will send an email if the user changes their email address to re-verify it. It is released as open source under an MIT license. Below is the link to the github source.</p><p><a href="https://github.com/delay/sveltekit-auth">GitHub - delay/sveltekit-auth: This is a Sveltekit Auth project. It utilizes Lucia for authentication, shadcn-svelte for ui elements, Prisma for database connectivity and type safety, Lucide for icons, Zod and Superforms to handle forms and validation and Sveltekit.</a></p><p>While creating this project, I made use of several great videos and tutorials from <a href="https://www.youtube.com/@huntabyte">Huntabyte</a> (who also developed the svelte port for shadcn) and <a href="https://www.youtube.com/@JoyofCodeDev">Joy of Code</a>. Both have great tutorials for all things related to Sveltekit.</p><p>This project creates an email and password user log in system and is my attempt to make something production ready with all of the usual features you expect. You can create new users and sign them in. It has user roles. It will verify a users email address. You can edit your profile including changing your email address and password. You can reset your password in case you forgot it. You can also change themes and have a light and dark mode. I didn’t see any examples utilizing these frameworks that had all of these necessary features.</p><p>It has a logging system for errors which I have tracked in Axiom. I wrote a separate article about the logging system <a href="https://jeffmcmorris.medium.com/awesome-logging-in-sveltekit-6afa29c5892c">here</a>.</p><p>I picked <a href="https://lucia-auth.com/">Lucia</a> for auth because it had great documentation and seemed to be in active development and was very full featured. It can provide authentication for OAuth providers as well. I always want to have a fallback for email and password, so that is what I chose to make for this project.</p><p><a href="https://www.shadcn-svelte.com/">shadcn-svelte</a> is another great project with a really nice development experience. It has beautiful ui elements that are very easy to use.</p><p><a href="https://www.prisma.io/">Prisma</a> is another great package and it is used for database connectivity and type safety. It works with many databases so it’s easy to change your database with one line of code. It has an easy to use ORM that cuts back on the amount of code you need to write.</p><p><a href="https://zod.dev/">Zod</a> is a typescript schema validation that allows you to easily validate your input in projects. It is very easy to setup what your data should look like to validate against.</p><p>Finally <a href="https://superforms.vercel.app/">Superforms</a> makes it easy to work with forms in Sveltekit. It cuts down a lot on boilerplate code when working with forms.</p><p>This was the first time working with many of these packages, but they really do streamline much of the Sveltekit development process. If there are any mistakes, please open up an issue on the project. Also I was pleasantly surprised at the scores from <a href="https://pagespeed.web.dev/">Google PageSpeed Insights</a>. This project scored a 100% in all metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q8MsK_jcWyRESkd_" /></figure><h3>File Structure for the App</h3><p>sample.env — private environmental server side variables that must be set. Rename to.env and supply your personal project settings.</p><p>/prisma/schema.prisma — holds the prism schema which is the design of your data in the app and db. Currently holds the auth schema for Lucia auth.</p><h3>/src/</h3><p>app.d.ts — holds type definitions for lucia and can hold your additional types for other features.</p><p>hooks.server.ts — holds a Lucia auth handle function.</p><p>theme.postcss — holds a custom theme for skeleton. This can be set in /routes/+layout.svelte. Comment out the theme-skeleton and add in theme.postcss. You can create your own custom theme <a href="https://www.skeleton.dev/docs/generator">https://www.skeleton.dev/docs/generator</a>. There are also lots of premade themes included with sveltekit. To use those, change theme-skeleton.css to theme-modern.css or another theme name.</p><h3>/lib</h3><h3>/_helpers</h3><p>convertNameToInitials.ts — function for making initials from first and last name of user for the avatar.</p><h3>/components</h3><p>/logo — used as the logo throughout the app.</p><p>/navigation — navigation menu links used in /routes/+layout.svelte. They change based on whether user is logged in or not.</p><p>/ui — our shadcn ui components. Contains many components related to that.</p><h3>/config</h3><p>constants.ts — all of the public constants that do not need to be hidden server side. I prefer this to naming constants PUBLIC_WHATEVER in the .env file, which is another option. I prefer to keep my .env file with only server side env variables.</p><p>email-messages.ts — this is where I keep all of the email messages that need to be sent. It makes it easier in case changes need to be made to the emails that are sent out.</p><p>prima.ts — file used to initialize the prisma client.</p><p>zod-schemas.ts — holds the schema used in zod. This defines how our form data needs to be validated.</p><h3>/server</h3><p>email-send.ts — this handles our email sending with AWS SES. It only runs server side to keep your credentials hidden.</p><p>lucia.ts- this initializes the lucia-auth package for handling our auth functions. It also holds the extra custom fields we added to the user.</p><p>log.ts- special log routine to provide debug info about our app.</p><h3>/routes</h3><p>+layout.server.ts — gets the user info from lucia-auth if available so we can access it in our app.</p><p>+layout.svelte — overall site layout which is inherited by the rest of our app.</p><p>+page.svelte-basic info about our app</p><p>+error.svelte-error message for problem routes.</p><h3>/(legal)/terms</h3><p>Holds our terms and conditions page. Do not use this for your own website as I just used ChatGPT to make this. You should consult a legal professional to develop the terms for your own app.</p><h3>/(legal)/privacy</h3><p>Holds our privacy policy page. Do not use this for your own website as I just used ChatGPT to make this. You should consult a legal professional to develop the privacy policy for your own app.</p><h3>/auth</h3><h3>/password/reset</h3><p>This holds the password reset form and function to send a password reset email when the user enters there email address,</p><h3>/password/update-[token]</h3><p>This allows the user to actually put in the new password, the token comes from the email from the users reset request. Anything in [] is able to be accessed as a parameter in Sveltekit, so [token] can be accessed via (token = event.params.token).</p><h3>/password/update-[token]/success</h3><p>This is the message the user sees if there reset was successful.</p><h3>/profile</h3><p>This allows the user to update their profile with new information. If they change their email address we also un-verify them and send them an email asking them to reconfirm their email. We also send an email to their old address telling them this change was made with the old and new address so that the data can be reset manually if the users account was hacked.</p><h3>/sign-in</h3><p>Page and functions for signing in the user.</p><h3>/sign-out</h3><p>Function for signing out the user.</p><h3>/sign-up</h3><p>Page and functions for signing up the user.</p><h3>/verify/email</h3><p>This page asks user to check there email and verify it.</p><h3>/verify/email-[token]</h3><p>This page confirms the email address by verifying the token the user received in his email account.</p><h3>/verify/resend-email-[email]</h3><p>This resends the verify email in case the user didn’t receive or lost the email.</p><h3>/(protected)</h3><p>This route group is only allowed to be accessed when a user is logged in.</p><p>Hopefully you may find some of this code useful for your own project. Please feel free to use it in any project.</p><p><a href="https://github.com/delay/sveltekit-auth">GitHub - delay/sveltekit-auth: This is a Sveltekit Auth project. It utilizes Lucia for authentication, shadcn-svelte for ui elements, Prisma for database connectivity and type safety, Lucide for icons, Zod and Superforms to handle forms and validation and Sveltekit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1923a8217bec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Awesome Logging in Sveltekit]]></title>
            <link>https://jeffmcmorris.medium.com/awesome-logging-in-sveltekit-6afa29c5892c?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/6afa29c5892c</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[sveltekit]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[logging]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Fri, 26 May 2023 03:46:43 GMT</pubDate>
            <atom:updated>2024-02-23T00:48:24.249Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YgipQNLB_-QWh9zKILQ9Dg.jpeg" /><figcaption>Data dashboards can be created from the captured logging data</figcaption></figure><p>I wanted to create a way to log events in my app. I wanted it to be easy, yet powerful. I wanted to know if functions were running slow and I wanted to capture any errors my app would have. I also didn’t want it to be difficult to to track something, since I am lazy:-)</p><p>I use the awesome logging service <a href="https://axiom.co/">Axiom</a> which has a very generous free tier to capture my log data, but you could use a different service if you like or even no service if you just want to use it in dev mode.</p><p>After watching a couple of great tutorials from <a href="https://www.youtube.com/watch?v=UJ3JtNIifR8">huntabyte</a> and <a href="https://www.youtube.com/watch?v=Kzrz7GZ9pIg">joy of code</a>, I decided the best place to capture the log would be in the +hooks.server.ts file. That way I could capture a lot of information without having to do much of anything for most pages.</p><h3><strong>Here is all of the info I want to track.</strong></h3><ul><li><strong>level</strong>: (info or error),</li><li><strong>method</strong>: GET or POST,</li><li><strong>path</strong>: location of request,</li><li><strong>status</strong>: http status code,</li><li><strong>timeInMs</strong>: how long the request took in milliseconds</li><li><strong>user</strong>: the users email address if logged in.</li><li><strong>userId</strong>: the users Id if logged in.</li><li><strong>referrer:</strong> the referring page. If the referrer is local I just put the referring path.</li><li><strong>parameters in the url</strong>: I capture any parameters attached to the url. so if you were running a campaign you could add <a href="https://yourdomain.com/?campaign=my-ad-campaign">https://yourdomain.com/?campaign=my-ad-campaign</a>&amp;ad=ad-banner-1 and it would capture any of these options also.</li><li><strong>message and track options</strong>: In addition I created two special ways to add events into the log. I have a track variable and a message variable. By adding event.locals.message or event.locals.track you can pass in an object or string and this data will also be tracked.</li><li><strong>errors</strong>: If your app has an error, three other pieces of data are gathered. There is an event.locals.error which is a string you can pass for when an error happens that is planned for. There is also an errorId which is a unique number we pass to the user to help with troubleshooting and reviewing our logs. Finally we pass the error stack trace through events.local.errorsStackTrace.</li></ul><p>Here is an example of what I capture for each request to the server, it includes just the basics, but could have a lot more info depending on what variables are passed in.</p><pre>{&quot;level&quot;:&quot;info&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;path&quot;:&quot;/dashboard&quot;,&quot;status&quot;:200,&quot;timeInMs&quot;:70,&quot;user&quot;:&quot;email@domain.com&quot;,&quot;userId&quot;:&quot;xjsjldwiieirhdls&quot;,&quot;referer&quot;:&quot;https://google.com&quot;}</pre><p>First I needed to add some new type info to my app.d.ts for some new variables I would use to do the tracking.</p><pre>//app.d.ts<br>declare global {<br> namespace App {<br>  interface Locals {<br>   startTimer: number;<br>   error: string;<br>   errorId: string;<br>   errorStackTrace: string;<br>   message: unknown;<br>   track: unknown;<br>  }<br>  interface Error {<br>   code?: string;<br>   errorId?: string;<br>  }<br> }<br>}</pre><p>Next I created a file called: log.ts. I then pass in the event which comes from hook.server.ts and an http status code.</p><pre>import { Client } from &#39;@axiomhq/axiom-node&#39;;<br>import { AXIOM_TOKEN, AXIOM_ORG_ID, AXIOM_DATASET } from &#39;$env/static/private&#39;;<br>import getAllUrlParams from &#39;$lib/_helpers/getAllUrlParams&#39;;<br>import parseTrack from &#39;$lib/_helpers/parseTrack&#39;;<br>import parseMessage from &#39;$lib/_helpers/parseMessage&#39;;<br>import { DOMAIN } from &#39;$lib/config/constants&#39;;<br><br>// eslint-disable-next-line @typescript-eslint/ban-ts-comment<br>//@ts-ignore<br>export default async function log(statusCode: number, event) {<br> try {<br>  const client = new Client({<br>   token: AXIOM_TOKEN,<br>   orgId: AXIOM_ORG_ID<br>  });<br>  let level = &#39;info&#39;;<br>  if (statusCode &gt;= 400) {<br>   level = &#39;error&#39;;<br>  }<br>  const error = event?.locals?.error || undefined;<br>  const errorId = event?.locals?.errorId || undefined;<br>  const errorStackTrace = event?.locals?.errorStackTrace || undefined;<br>  let urlParams = {};<br>  if (event?.url?.search) {<br>   urlParams = await getAllUrlParams(event?.url?.search);<br>  }<br>  let messageEvents = {};<br>  if (event?.locals?.message) {<br>   messageEvents = await parseMessage(event?.locals?.message);<br>  }<br>  let trackEvents = {};<br>  if (event?.locals?.track) {<br>   trackEvents = await parseTrack(event?.locals?.track);<br>  }<br><br>  let referer = event.request.headers.get(&#39;referer&#39;);<br>  if (referer) {<br>   const refererUrl = await new URL(referer);<br>   const refererHostname = refererUrl.hostname;<br>   if (refererHostname === &#39;localhost&#39; || refererHostname === DOMAIN) {<br>    referer = refererUrl.pathname;<br>   }<br>  } else {<br>   referer = undefined;<br>  }<br>  const logData: object = {<br>   level: level,<br>   method: event.request.method,<br>   path: event.url.pathname,<br>   status: statusCode,<br>   timeInMs: Date.now() - event?.locals?.startTimer,<br>   user: event?.locals?.user?.email,<br>   userId: event?.locals?.user?.userId,<br>   referer: referer,<br>   error: error,<br>   errorId: errorId,<br>   errorStackTrace: errorStackTrace,<br>   ...urlParams,<br>   ...messageEvents,<br>   ...trackEvents<br>  };<br>  console.log(&#39;log: &#39;, JSON.stringify(logData));<br>  await client.ingestEvents(AXIOM_DATASET, [logData]);<br> } catch (err) {<br>  throw new Error(`Error Logger: ${JSON.stringify(err)}`);<br> }<br>}</pre><p>There are three support functions for the log.ts. These convert the data to objects to be ingested by our log.ts.</p><pre>//getAllUrlParams.ts<br>export default async function getAllUrlParams(url: string): Promise&lt;object&gt; {<br> let paramsObj = {};<br> try {<br>  url = url?.slice(1); //remove leading ?<br>  if (!url) return {}; //if no params return<br>  paramsObj = await Object.fromEntries(await new URLSearchParams(url));<br> } catch (error) {<br>  console.log(&#39;error: &#39;, error);<br> }<br> return paramsObj;<br>}</pre><pre>//parseMessage.ts<br>export default async function parseMessage(message: unknown): Promise&lt;object&gt; {<br> let messageObj = {};<br> try {<br>  if (message) {<br>   if (typeof message === &#39;string&#39;) {<br>    messageObj = { message: message };<br>   } else {<br>    messageObj = message;<br>   }<br>  }<br> } catch (error) {<br>  console.log(&#39;error: &#39;, error);<br> }<br> return messageObj;<br>}</pre><pre>//parseTrack.ts<br>export default async function parseTrack(track: unknown): Promise&lt;object&gt; {<br> let trackObj = {};<br> try {<br>  if (track) {<br>   if (typeof track === &#39;string&#39;) {<br>    trackObj = { track: track };<br>   } else {<br>    trackObj = track;<br>   }<br>  }<br> } catch (error) {<br>  console.log(&#39;error: &#39;, error);<br> }<br> return trackObj;<br>}</pre><p>hooks.server.ts is how we call our log.ts file so it executes on every server request.</p><pre>//hooks.server.ts<br>import { redirect, type Handle } from &#39;@sveltejs/kit&#39;;<br>import type { HandleServerError } from &#39;@sveltejs/kit&#39;;<br>import log from &#39;$lib/server/log&#39;;<br><br><br><br>export const handleError: HandleServerError = async ({ error, event }) =&gt; {<br> const errorId = crypto.randomUUID();<br><br> // eslint-disable-next-line @typescript-eslint/ban-ts-comment<br> //@ts-ignore<br> event.locals.error = error?.toString() || undefined;<br> // eslint-disable-next-line @typescript-eslint/ban-ts-comment<br> //@ts-ignore<br> event.locals.errorStackTrace = error?.stack || undefined;<br> event.locals.errorId = errorId;<br> log(500, event);<br> return {<br>  message: &#39;An unexpected error occurred.&#39;,<br>  errorId<br> };<br>};<br><br><br>export const handle: Handle = async ({ event, resolve }) =&gt; {<br> const startTimer = Date.now();<br> event.locals.startTimer = startTimer;<br> const response = await resolve(event);<br> log(response.status, event);<br> return response;<br>};</pre><p>Finally we setup a custom +error.svelte to handle our custom error page which outputs the custom errorId. This is good if you have a user having trouble you can search your logs based on this string (special thanks to this <a href="https://www.youtube.com/watch?v=UJ3JtNIifR8">huntabyte tutorial</a> for this idea).</p><pre>&lt;!--+error.svelte--&gt;<br>&lt;script lang=&quot;ts&quot;&gt;<br> import { page } from &#39;$app/stores&#39;;<br>&lt;/script&gt;<br><br>&lt;div&gt;<br> {#if $page.status === 404}<br>  &lt;h1&gt;Page Not Found.&lt;/h1&gt;<br>  &lt;h3 class=&quot;mt-6&quot;&gt;&lt;a href=&quot;/&quot;&gt;Go Home&lt;/a&gt;&lt;/h3&gt;<br> {:else}<br>  &lt;h1 class=&quot;h1&quot;&gt;Unexpected Error&lt;/h1&gt;<br>  &lt;h3 class=&quot;mt-6&quot;&gt;We&#39;re investigating the issue.&lt;/h3&gt;<br> {/if}<br><br> {#if $page.error?.errorId}<br>  &lt;p class=&quot;mt-6&quot;&gt;Error ID: {$page.error.errorId}&lt;/p&gt;<br> {/if}<br>&lt;/div&gt;</pre><p>How to use the special parameters for passing in message and track. It’s very simple, in any function just pass in data like this. You can either pass a string or pass an object for each one. The special error message only takes a string but you could add this in when you catch an error.</p><pre>event.locals.message = &#39;sign in successful&#39;;<br>event.locals.track = { test: &#39;sign-in&#39;, test2: &#39;another value&#39; };<br>event.locals.error = &#39;some error message&#39;;<br></pre><p>So very easy, even for us lazy coders;-)</p><p>If you would like to see completed github project you can checkout my <a href="https://medium.com/@jeffmcmorris/sveltekit-auth-starter-4e1ff139891c">sveltekit auth starter project</a>, this logging system is a part of that.</p><p><a href="https://github.com/delay/sveltekit-auth-starter">GitHub - delay/sveltekit-auth-starter: This is a Sveltekit auth starter project. It utilizes Lucia for authentication, Skeleton for ui elements, Prisma for database connectivity and type safety, Lucide for icons, inlang for translation, Zod and Superforms to handle forms and validation and Sveltekit.</a></p><p>Anyway hopefully you will find this helpful for your own projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6afa29c5892c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sveltekit Auth Starter]]></title>
            <link>https://jeffmcmorris.medium.com/sveltekit-auth-starter-4e1ff139891c?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e1ff139891c</guid>
            <category><![CDATA[sveltekit]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[auth]]></category>
            <category><![CDATA[prisma]]></category>
            <category><![CDATA[zod]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Sun, 14 May 2023 00:01:29 GMT</pubDate>
            <atom:updated>2024-02-23T00:49:10.094Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-oJRLXc299bFOzDS-fnyA.png" /></figure><p>This is a Sveltekit Auth Starter Project. An example demo is <a href="https://sveltekit-auth.uv-ray.com/">here</a>. It is an open source auth starter project utilizing <a href="https://lucia-auth.com/">Lucia</a> for authentication, <a href="https://www.skeleton.dev/">Skeleton</a> for ui elements, <a href="https://lucide.dev/">Lucide</a> for icons, <a href="https://inlang.com/">Inlang</a> for language translations and internationalization, <a href="https://www.prisma.io/">Prisma</a> for database connectivity and type safety and <a href="https://kit.svelte.dev/">Sveltekit</a> for the javascript framework. I also used <a href="https://zod.dev/">Zod</a> and <a href="https://superforms.vercel.app/">Superforms</a> to handle form validation and management. It has email verification, password reset, and will send an email if the user changes their email address to re-verify it. It is released as open source under an MIT license.</p><p><strong>Here is the source code for the project:</strong></p><p><a href="https://github.com/delay/sveltekit-auth-starter">GitHub - delay/sveltekit-auth-starter: This is a Sveltekit auth starter project. It utilizes Lucia for authentication, Skeleton for ui elements, Prisma for database connectivity and type safety, Lucide for icons, inlang for translation, Zod and Superforms to handle forms and validation and Sveltekit.</a></p><p>While creating this project, I made use of several great videos and tutorials from <a href="https://www.youtube.com/@huntabyte">Huntabyte</a> and <a href="https://www.youtube.com/@JoyofCodeDev">Joy of Code</a>. Both have great tutorials for all things related to Sveltekit.</p><p>This project creates an email and password user log in system and is my attempt to make something production ready with all of the usual features you expect. You can create new users and sign them in. It has user roles. It will verify a users email address. You can edit your profile including changing your email address and password. You can reset your password in case you forgot it. You can also change themes and have a light and dark mode. I didn’t see any examples utilizing these frameworks that had all of these necessary features.</p><p>I picked <a href="https://lucia-auth.com/">Lucia</a> for auth because it had great documentation and seemed to be in active development and was very full featured. It can provide authentication for OAuth providers as well. I always want to have a fallback for email and password, so that is what I chose to make for this project.</p><p><a href="https://www.skeleton.dev/">Skeleton</a> is another great project with a really nice development experience. Perhaps the coolest feature is it makes use of <a href="https://www.skeleton.dev/docs/tokens">design tokens</a>. This allows for lots of customization just by modifying the <a href="https://www.skeleton.dev/docs/generator">theme.css</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qo_ZLFxpaijwvOK_7vbyFw.png" /></figure><p><a href="https://www.prisma.io/">Prisma</a> is another great package and it is used for database connectivity and type safety. It works with many databases so it’s easy to change your database with one line of code. It has an easy to use ORM that cuts back on the amount of code you need to write.</p><p><a href="https://zod.dev/">Zod</a> is a typescript schema validation that allows you to easily validate your input in projects. It is very easy to setup what your data should look like to validate against.</p><p>Finally <a href="https://superforms.vercel.app/">Superforms</a> makes it easy to work with forms in Sveltekit. It cuts down a lot on boilerplate code when working with forms.</p><p>This was the first time working with many of these packages, but they really do streamline much of the Sveltekit development process. If there are any mistakes, please open up an issue on the project. Also I was pleasantly surprised at the scores from <a href="https://pagespeed.web.dev/">Google PageSpeed Insights</a>. This project scored a 100% in all metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SlpRE8RL3KIJW8af7P8otw.png" /></figure><h3>File Structure for the App</h3><p><strong>sample.env</strong> — private environmental server side variables that must be set. Rename to.env and supply your personal project settings.</p><p><strong>/prisma/schema.prisma</strong> — holds the prism schema which is the design of your data in the app and db. Currently holds the auth schema for Lucia auth.</p><h3><strong>/src/</strong></h3><p><strong>app.d.ts </strong>— holds type definitions for lucia and can hold your additional types for other features.</p><p><strong>hooks.server.ts </strong>— holds a Lucia auth handle function.</p><p><strong>theme.postcss </strong>— holds a custom theme for skeleton. This can be set in /routes/+layout.svelte. Comment out the theme-skeleton and add in theme.postcss. You can create your own custom theme <a href="https://www.skeleton.dev/docs/generator">https://www.skeleton.dev/docs/generator</a>. There are also lots of premade themes included with sveltekit. To use those, change theme-skeleton.css to theme-modern.css or another theme name.</p><h3>/lib</h3><h3>/_helpers</h3><p><strong>convertNameToInitials.ts</strong> — function for making initials from first and last name of user for the avatar.</p><h3><strong>/components</strong></h3><p><strong>footer.svelte </strong>— footer in the app, used in /routes/+layout.svelte</p><p><strong>logo.svelte </strong>— used as the logo throughout the app.</p><p><strong>navigation.svelte</strong> — navigation menu links used in /routes/+layout.svelte. They change based on whether user is logged in or not.</p><p><strong>sign-in.svelte </strong>— sign in form component used in /auth/sign-in/+page.svelte</p><p><strong>sign-up.svelte</strong> — sign up form component used in /auth/sign-up/+page.svelte</p><h3>/config</h3><p><strong>constants.ts </strong>— all of the public constants that do not need to be hidden server side. I prefer this to naming constants PUBLIC_WHATEVER in the .env file, which is another option. I prefer to keep my .env file with only server side env variables.</p><p><strong>email-messages.ts</strong> — this is where I keep all of the email messages that need to be sent. It makes it easier in case changes need to be made to the emails that are sent out.</p><p><strong>prima.ts — </strong>file used to initialize the prisma client.</p><p><strong>zod-schema.ts</strong> — holds the schema used in zod. This defines how our form data needs to be validated.</p><h3>/server</h3><p><strong>email-send.ts</strong> — this handles our email sending with AWS SES. It only runs server side to keep your credentials hidden.</p><p><strong>lucia.ts</strong>- this initializes the lucia-auth package for handling our auth functions. It also holds the extra custom fields we added to the user.</p><h3>/routes</h3><p><strong>+layout.server.ts </strong>— gets the user info from lucia-auth if available so we can access it in our app.</p><p><strong>+layout.svelte</strong> — overall site layout which is inherited by the rest of our app.</p><p><strong>+page.svelte</strong>-basic info about our app</p><h3>/auth</h3><p><strong>+layout.svelte</strong>-handles our layout for the auth section.</p><h3>/legal</h3><p><strong>+layout@.svelte </strong>— resets our layout for the legal section so it doesn’t inherit the auth layout. add the @ at the end to do this.</p><h3>/legal/terms</h3><p>Holds our terms and conditions page. Do not use this for your own website as I just used ChatGPT to make this. You should consult a legal professional to develop the terms for your own app.</p><h3>/legal/privacy</h3><p>Holds our privacy policy page. Do not use this for your own website as I just used ChatGPT to make this. You should consult a legal professional to develop the privacy policy for your own app.</p><h3>/password/reset</h3><p>This holds the password reset form and function to send a password reset email when the user enters there email address,</p><h3>/password/update-[token]</h3><p>This allows the user to actually put in the new password, the token comes from the email from the users reset request. Anything in [] is able to be accessed as a parameter in Sveltekit, so [token] can be accessed via (token = event.params.token).</p><h3>/password/update-[token]/success</h3><p>This is the message the user sees if there reset was successful.</p><h3>/profile</h3><p>This allows the user to update their profile with new information. If they change their email address we also un-verify them and send them an email asking them to reconfirm their email. We also send an email to their old address telling them this change was made with the old and new address so that the data can be reset manually if the users account was hacked.</p><h3>/sign-in</h3><p>Page and functions for signing in the user.</p><h3>/sign-out</h3><p>Function for signing out the user.</p><h3>/sign-up</h3><p>Page and functions for signing up the user.</p><h3>/verify/email</h3><p>This page asks user to check there email and verify it.</p><h3>/verify/email-[token]</h3><p>This page confirms the email address by verifying the token the user received in his email account.</p><h3>/verify/resend-email-[token]</h3><p>This resends the verify email token email in case the user didn’t receive or lost the email.</p><h3>/protected</h3><p>This area is only allowed to be accessed when a user is logged in.</p><p>Hopefully you may find some of this code useful for your own project. Please feel free to use it in any project.</p><p><a href="https://github.com/delay/sveltekit-auth-starter">GitHub - delay/sveltekit-auth-starter: This is a Sveltekit auth starter project. It utilizes Lucia for authentication, Skeleton for ui elements, Prisma for database connectivity and type safety, Lucide for icons, inlang for translation, Zod and Superforms to handle forms and validation and Sveltekit.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e1ff139891c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why did Elon Musk temporarily suspend a bunch of “Journalists” from Twitter?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://jeffmcmorris.medium.com/why-did-elon-musk-temporarily-suspend-a-bunch-of-journalists-from-twitter-1b895836cb4e?source=rss-3a79afe75f66------2"><img src="https://cdn-images-1.medium.com/max/2600/0*_e3IJAYzaYYXsPN7" width="4096"></a></p><p class="medium-feed-snippet">If you have been following the news lately, you will have read that Elon Musk began banning journalists who had been critical of him. The&#x2026;</p><p class="medium-feed-link"><a href="https://jeffmcmorris.medium.com/why-did-elon-musk-temporarily-suspend-a-bunch-of-journalists-from-twitter-1b895836cb4e?source=rss-3a79afe75f66------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jeffmcmorris.medium.com/why-did-elon-musk-temporarily-suspend-a-bunch-of-journalists-from-twitter-1b895836cb4e?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b895836cb4e</guid>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[elon-musk]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Sun, 18 Dec 2022 20:57:09 GMT</pubDate>
            <atom:updated>2022-12-18T21:21:59.662Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How Elon Musk will rebuild Twitter into a successful company.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">There are a lot of negative articles on Elon Musk&#x2019;s Twitter acquisition. Unfortunately most of these articles are very shallow and have&#x2026;</p><p class="medium-feed-link"><a href="https://jeffmcmorris.medium.com/how-elon-musk-will-rebuild-twitter-into-a-successful-company-e87b8b58d727?source=rss-3a79afe75f66------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jeffmcmorris.medium.com/how-elon-musk-will-rebuild-twitter-into-a-successful-company-e87b8b58d727?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/e87b8b58d727</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 05:00:11 GMT</pubDate>
            <atom:updated>2022-11-05T01:57:45.934Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[GetX Google Sheets Translation Code Generator]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://jeffmcmorris.medium.com/getx-google-sheets-translation-code-generator-b970543d67fc?source=rss-3a79afe75f66------2"><img src="https://cdn-images-1.medium.com/max/736/0*np0ZcUgEyUHVBTv1" width="736"></a></p><p class="medium-feed-snippet">When handling localization for my app I was using the excellent https://pub.dev/packages/flutter_sheet_localization package. I have also&#x2026;</p><p class="medium-feed-link"><a href="https://jeffmcmorris.medium.com/getx-google-sheets-translation-code-generator-b970543d67fc?source=rss-3a79afe75f66------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jeffmcmorris.medium.com/getx-google-sheets-translation-code-generator-b970543d67fc?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/b970543d67fc</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[getx]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[code-generator]]></category>
            <category><![CDATA[translation]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Wed, 14 Apr 2021 01:46:19 GMT</pubDate>
            <atom:updated>2021-04-14T01:46:19.919Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The WHO is wrong on the origins of COVID-19.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://jeffmcmorris.medium.com/the-who-is-wrong-on-the-origins-of-covid-19-f9a13cdc2ab2?source=rss-3a79afe75f66------2"><img src="https://cdn-images-1.medium.com/max/2600/1*dvt4OpFWI2a-YiIc-oZIJw.jpeg" width="5616"></a></p><p class="medium-feed-snippet">There are three hypotheses proposed by the WHO for the spread of COVID-19.</p><p class="medium-feed-link"><a href="https://jeffmcmorris.medium.com/the-who-is-wrong-on-the-origins-of-covid-19-f9a13cdc2ab2?source=rss-3a79afe75f66------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jeffmcmorris.medium.com/the-who-is-wrong-on-the-origins-of-covid-19-f9a13cdc2ab2?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9a13cdc2ab2</guid>
            <category><![CDATA[origins]]></category>
            <category><![CDATA[hypothesis]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[sars-cov2]]></category>
            <category><![CDATA[who]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 04:19:41 GMT</pubDate>
            <atom:updated>2021-02-10T06:01:28.723Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[GetX Flutter Firebase Auth Example]]></title>
            <link>https://jeffmcmorris.medium.com/getx-flutter-firebase-auth-example-b383c1dd1de2?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/b383c1dd1de2</guid>
            <category><![CDATA[example]]></category>
            <category><![CDATA[auth]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[getx]]></category>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Sat, 01 Aug 2020 05:19:13 GMT</pubDate>
            <atom:updated>2021-05-21T13:45:25.347Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKSIgkZpss30GYT9TwQcJg.png" /></figure><p>GetX is a relatively new package for Flutter that provides the missing link in making Flutter development simpler. I recently converted a <a href="https://medium.com/@jeffmcmorris/flutter-firebase-auth-starter-project-b0f91a6503b7">firebase auth project</a> I had created which used provider for state management. Switching to GetX simplified many of the pain points I have had with Flutter development. I no longer was having to pass context into functions. I could also better separate my logic from the UI. GetX also greatly simplifies routing, displaying snackbars and dialogs.</p><p>There are some really good projects and tutorials that I made use of in making <a href="https://github.com/delay/flutter_starter">this project</a>. See these links for more help with GetX. <a href="https://github.com/jonataslaw/getx">GetX Documentation</a>, <a href="https://medium.com/@loicgeek/flutter-how-to-create-a-todo-app-using-firebase-firestore-and-firebase-authentication-with-getx-89bdaacc6de6">Todo GetX example</a>, <a href="https://www.youtube.com/watch?v=CNpXbeI_slw">Amateur Coder GetX Videos</a>, <a href="https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3">Theme Example</a> and <a href="https://medium.com/@fayaz07/dont-kill-app-s-ui-thread-for-showing-loading-indicators-809e5a992230">Loading Overlay</a>.</p><p>So why would you want to use GetX? Let me give you an example of how it simplified my own code. When I used Provider there was a lot more boilerplate code. It felt much more esoteric to use. GetX made my code easier to understand. Here is my code for main.dart original vs. GetX.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sg7dajwS-q-I_G4KLDx_ow.png" /></figure><p>Once you understand the GetX way it becomes much easier to organize your code and separate your concerns between your UI and functions. For instance when calling a function in the UI I was having to handle the results from the function and display snackbars with the results. With GetX I was able to move the snackbars into the actual function which makes more sense since I no longer have to send success and fail messages in and out of functions. Below I show a button which signs in the user with the old way vs GetX way. I prefer the GetX way even though it isn’t a lot shorter, but I like having my logic all separated from the UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWsqOuTY1xvqkVvGrt2BLQ.png" /></figure><p>GetX also has a storage package called <a href="https://github.com/jonataslaw/get_storage">get_storage</a>. It can take the place of shared preferences. It simplifies the way to store data on the device. Here is another example of before and after code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyYboVrB1BYcMkeHsSNeSw.png" /></figure><p>There are many other features of GetX to make things simpler, such as working with themes, getting various device settings, etc. This package simplifies a lot of the problems developers face daily when building an app.</p><p>When building an auth project there are a lot of the features you need for a production flutter project. I wanted light and dark mode theming but also the ability to detect and switch themes automatically. I needed the ability to switch between languages easily and automatically detect the user’s language. I wanted a simple way to handle translating from english (the only language I know, unfortunately). This is accomplished through using a <a href="https://jeffmcmorris.medium.com/getx-google-sheets-translation-code-generator-b970543d67fc">small command line app</a> to generate the getX code which allows you to put your translation into a <a href="https://docs.google.com/spreadsheets/d/1oS7iJ6ocrZBA53SxRfKF0CG9HAaXeKtzvsTBhgG4Zzk/edit#gid=0">google sheet</a> and easily translate into other languages. Also I needed a way to <a href="https://medium.com/firebase-developers/patterns-for-security-with-firebase-group-based-permissions-for-cloud-firestore-72859cdec8f6">do simple user roles</a> and it needed to be secure. I see a lot of auth packages including roles in the user’s collection in firestore which is usually editable by that same user. This would make it trivial for the user to assign himself admin privileges. I also wanted to show how to put some basic rules in firestore to secure it. Finally I wanted to have a way the user could alter their profile and change their email or password.</p><p>To handle the language translation you need to create a translation for your app in google sheets. Then open /helpers/update_localizations.dart and replace the docID and sheetId with your own documentId and sheetId. After doing that your will need to drop to the command line and go into the helpers directory. Then type: `dart update_localizations.dart`. This will create or overwrite the localization.g.dart file with your custom translation. There should not be a need to edit this file directly. Every time you make changes to your translation you will need to re-run this generator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*9-A7El_nRDBz-ecK" /></figure><p>You can copy my <a href="https://docs.google.com/spreadsheets/d/1oS7iJ6ocrZBA53SxRfKF0CG9HAaXeKtzvsTBhgG4Zzk/edit#gid=0">sheet</a> as a starting point for your own app. The cool thing about using a google sheet is you can have google translate a field with a simple google formula: =GOOGLETRANSLATE(B4,en,fr) This says translate the phrase in field B4 from english to french.</p><p>To handle user roles I created a separate admin collection and added a document with the same document id as the uid of my user. The reason to do this is to make it secure as explained in this <a href="https://medium.com/firebase-developers/patterns-for-security-with-firebase-group-based-permissions-for-cloud-firestore-72859cdec8f6">medium article</a>. I went with the second method explained in that article. If we had just put the roles as a field in the users collection any user could have upgraded themselves to an admin user. So by moving the admin role to a separate collection we can create some rules in firestore that allow the user to update fields about themselves without giving them access to change the role they were assigned. You can also generate other roles for the user by simply adding additional collections for the other roles..</p><p>The rules I have setup in firestore for this project are fairly simple. Here are the rules I have created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*_lmwiYDofWZd0Kn0" /></figure><p>The first rule matches any user in the admin collection and allows you to read that document only. No one is allowed to write to this collection. I manually add my admin users through the firebase console. The second rule allows the user to read and write only if the user matches the currently logged in user. So a user can only change information about themselves. Here is how my collections are setup in firestore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uFxZGvnPvviMebQ5" /></figure><p>Finally I wanted to explain a little bit about my ui. I try to control as much as possible with the theme. You can change a lot about the look with the user interface by changing the theme. I am still learning about what all can be changed with just the theme. I also break out small ui components into a separate components folder. Then I make a custom widget instead of using the standard widget directly. This allows me to make changes in one spot if I decide to make ui changes to say a form field in my form_input_field.dart instead of changing a bunch of TextFormField widgets spread through a dozen files.</p><h3>Overview of project</h3><p><strong>main.dart</strong> — contains info for maintaining the state of the app for the theme, language and user. It initializes language and theme settings. Sets up routing.</p><h3>/constants/</h3><p><strong>app_themes.dart</strong> — contains info related to our light and dark themes.</p><p><strong>globals.dart</strong> — contains some global app settings</p><p><strong>app_routes.dart </strong>— contains the app routes.</p><h3>/controllers/</h3><p><strong>auth_controller.dart</strong> — our user and authentication functions for creating, logging in and out our user and saving our user data.</p><p><strong>language_controller.dart</strong> — saves and loads our selected language.</p><p><strong>theme_controller.dart</strong> — saves and loads our selected theme.</p><h3>/helpers/</h3><p><strong>validator.dart</strong> — contains some validation functions for our form fields.</p><p><strong>update_localizations.dart</strong> — command line dart app that generates the localization.g.dart file.</p><p><strong>localizations.g.dart</strong> — this file is generated from our google sheet (do not manually edit this file).</p><h3>/models/</h3><p><strong>user_model.dart</strong> — contains the model for our user saved in firestore.</p><p><strong>menu_option_model.dart</strong> — contains our model for our language options and theme options in settings.</p><h3>/ui/</h3><p><strong>home_ui.dart </strong>— contains the ui for the home which shows info about the user.</p><p><strong>settings_ui.dart</strong> — contains the settings screen for setting the theme and language and some user settings.</p><p><strong>splash_ui.dart </strong>— contains the initial loading screen, currently just a circular progress indicator.</p><h3>/ui/auth/</h3><p><strong>reset_password_ui.dart</strong> — sends a password reset email to the user.</p><p><strong>sign_in_ui.dart</strong> — allows user to login with email and password.</p><p><strong>sign_up_ui.dart </strong>— allows user to create a new account.</p><p><strong>update_profile_ui.dart</strong> — allows user to change his email or name.</p><h3>/ui/components/</h3><p><strong>avatar.dart</strong> — displays a user avatar on the home_ui.</p><p><strong>dropdown_picker.dart</strong> — shows a dropdown list.</p><p><strong>dropdown_picker_with_icon.dart </strong>— shows a dropdown list with icons.</p><p><strong>form_input_field.dart </strong>— handles our form field elements.</p><p><strong>form_input_field_with_icon.dart</strong> — handles our form field elements but has an icon too.</p><p><strong>form_vertical_spacing.dart</strong> — just a space in the ui.</p><p><strong>label_button.dart</strong> — one type of button in ui.</p><p><strong>loading.dart</strong> — circular loading indicator overlay.</p><p><strong>logo_graphic_header.dart</strong> — a graphic displayed in our ui.</p><p><strong>primary_button.dart</strong> — another button in the ui.</p><p><strong>segmented_selector.dart</strong> — a control used to select the theme.</p><p><strong>sliding_segmented_control.dart</strong> — some modifications of the Cupertino control which is used by segmented_selector.dart.</p><p>Provider is also a great package and what I was using for Flutter development until I found GetX. Flutter is still new and evolving fast. It is fun to watch it progress so rapidly with the help of the Flutter community!</p><p>Anyway hopefully this project will help someone. Feel free to use any of it, I didn’t create all of this code as parts of it came from watching the tutorials and reviewing the projects mentioned above. Make sure you <a href="https://firebase.google.com/docs/flutter/setup?platform=android">setup firebase</a> with your project. The code is available on Github <a href="https://github.com/delay/flutter_starter">here</a>.</p><p><a href="https://github.com/delay/flutter_starter">delay/flutter_starter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b383c1dd1de2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Firebase Auth Starter Project]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://jeffmcmorris.medium.com/flutter-firebase-auth-starter-project-b0f91a6503b7?source=rss-3a79afe75f66------2"><img src="https://cdn-images-1.medium.com/max/2388/1*wOmpyN5Poy2Y7u4NMmpj9g.png" width="2388"></a></p><p class="medium-feed-snippet">So why do another Auth project for flutter? There are dozens of projects already. Including this one I did last year when I was starting&#x2026;</p><p class="medium-feed-link"><a href="https://jeffmcmorris.medium.com/flutter-firebase-auth-starter-project-b0f91a6503b7?source=rss-3a79afe75f66------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jeffmcmorris.medium.com/flutter-firebase-auth-starter-project-b0f91a6503b7?source=rss-3a79afe75f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0f91a6503b7</guid>
            <dc:creator><![CDATA[Jeff McMorris]]></dc:creator>
            <pubDate>Sat, 02 May 2020 15:52:05 GMT</pubDate>
            <atom:updated>2020-05-07T00:08:30.544Z</atom:updated>
        </item>
    </channel>
</rss>