Code Monkey home page Code Monkey logo

pokeintents's Introduction

Cover

An app to show a simple implmentation of Apple's AppIntents framework. It uses only local JSON for its data, and UserDefaults for persisting user favourites. The goal is to show using intents, not how to build a super fancy app.

If you have an idea for a feature to add, please open a PR! 😊

Features

Listing Pokémon

You can query Pokémon inside shortcuts using a couple of different queries. It supports limiting and sorting.

The mechanism for comparators is a custom solution with an enum for each, allowing it to be easily extended for future properties.

Checkout PokemonQuery for more.

The shortcuts query editor.

Favourite/Unfavourite a Pokémon

Interacting with the user defaults is possible from the intents as they all run within your main apps container. You can favourite and unfavourite a pokemon directly from shortcuts.

The shortcuts query editor. Mew with a star showing that it was favourited.

Open with intents

On each pokemon page there's a Siri prompt to open that again with your voice. This is a simple solution using the latest NavigationStack api. This is also exposed to shortcuts.

The shortcuts query editor. The app with mew open.

Open without the app

You can use a shortcut to preview without opening the app. When you combine this with queries, it allows for entirely shortcut based viewing, to the point you may not even need to use the app.

The shortcuts query editor. A small preview view of mew.

Data

Source

The data for this app was generated using this query on pokeapi.co, and downloaded as a local JSON to avoid hitting someone elses API in sample code.

query GenOneQuery {
  pokemon_v2_pokemon(where: {pokemon_species_id: {_lt: 152}}, distinct_on: pokemon_species_id) {
    id
    name
    pokemon_v2_pokemonsprites {
      sprites
    }
    pokemon_v2_pokemonmoves {
      pokemon_v2_move {
        name
      }
    }
  }
}

Mapping

Mapping is quickly done using quicktype.io. There's some awkwardness with the sprites as they come down as a json string inside a json value, so we have to do some funky conversion to extract them. This is an area that could certainly be improved with a custom decoder.


Icon

pokeintents's People

Contributors

swiftyalex avatar

Stargazers

Jakub Petrík avatar Murad avatar Carlo Zottmann avatar zunda avatar Kyle2501 avatar Narcis avatar  avatar

Watchers

 avatar

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.