A beautiful iOS application built with SwiftUI that allows users to explore superheroes and villains from all comic universes using the SuperHero API.
| Heroes List | Hero Detail | Loading Screen |
|---|---|---|
| List of superheroes with images, alignment badges, and info | Detailed view with power stats, biography, appearance, and connections | Animated loading screen with progress indicator |
- Browse All Superheroes: Explore a comprehensive database of 731+ heroes and villains from all universes
- Infinite Scrolling: Seamless pagination with automatic loading of more characters
- Pull-to-Refresh: Easy content refresh with native SwiftUI gesture
- Detailed Information: View comprehensive details about each character:
- Power Statistics (Intelligence, Strength, Speed, Durability, Power, Combat)
- Biography (Full name, aliases, place of birth, publisher, alignment)
- Physical Appearance (Gender, race, height, weight, eye/hair color)
- Work Information (Occupation, base of operations)
- Connections (Group affiliations, relatives)
- Visual Indicators: Color-coded alignment badges (Good = Green, Bad = Red)
- Beautiful UI: Modern design with smooth animations and transitions
- Offline Support: Cached responses for better offline experience
- Dark Mode: Full support for iOS dark mode
The project follows a clean and simple architecture optimized for a small-scale application:
Marvel App/
├── Marvel_AppApp.swift # App entry point
├── ContentView.swift # Root view
├── APINetwork.swift # Network layer with singleton pattern
├── HeroesListView.swift # Main list view with pagination
├── HeroDetailView.swift # Character detail view with power stats
├── HeroCell.swift # Reusable character cell component
├── LoadingView.swift # Custom animated loading screen
├── ErrorView.swift # Error handling UI
└── Persistence.swift # Core Data configuration (for future use)
- APINetwork: Singleton network manager handling all SuperHero API communications with proper error handling
- Hero Models: Comprehensive codable structs including:
Hero: Main character model with all dataPowerStats: Character abilities and statsBiography: Character background and publisher infoAppearance: Physical characteristicsWork: Occupation and base informationConnections: Affiliations and relationships
- SwiftUI Views: Modern declarative UI with NavigationStack for iOS 16+
- iOS 17.0+
- Xcode 15.0+
- Swift 5.9+
This project uses only native Apple frameworks:
- SwiftUI: Modern declarative UI framework
- Foundation: Core networking and data handling
- CoreData: Data persistence (configured for future features)
The app uses the SuperHero API which provides:
- Access to 731+ superheroes and villains
- Comprehensive character information
- High-quality character images
- Simple token-based authentication
API Endpoints Used:
GET /api/{token}/{id}- Fetch character by IDGET /api/{token}/search/{name}- Search characters by name
- Get your free API token from SuperHero API
- Simply login with your GitHub account
- Your access token will be generated automatically
- Xcode 15 or later installed
- Clone the repository:
git clone https://github.com/yourusername/superhero-app.git
cd superhero-app- Open the project in Xcode:
open "Marvel App.xcodeproj"-
Update API Token:
Open APINetwork.swift and replace the token:
private let accessToken = "YOUR_ACCESS_TOKEN_HERE"
For Production (Recommended):
- Create a
Config.xcconfigfile - Add your token:
SUPERHERO_API_TOKEN = your_token_here - Update
APINetwork.swiftto read from environment
- Create a
-
Build and run the project (⌘ + R)
struct Hero: Codable, Identifiable, Hashable {
let id: String
let name: String
let powerstats: PowerStats?
let biography: Biography?
let appearance: Appearance?
let work: Work?
let connections: Connections?
let image: HeroImage?
}The APINetwork class provides:
- Singleton pattern for consistent state management
- Proper error handling with custom
APIErrorenum - URL session configuration with caching
- Multiple fetch methods:
getHeroes(offset:limit:)- Batch fetch heroes by ID rangegetHero(by:)- Fetch single hero by IDsearchHeroes(by:)- Search heroes by name
| View | Description |
|---|---|
HeroesListView |
Main view with character list and infinite scroll pagination |
HeroDetailView |
Comprehensive character information with power stats visualizations |
HeroCell |
Reusable list cell with hero thumbnail, alignment badge, and preview info |
LoadingView |
Animated loading screen with progress indicator |
ErrorView |
Error display with retry functionality |
- Power Stats Visualization: Progress bars showing character abilities
- Alignment Badges: Color-coded indicators (Green for heroes, Red for villains)
- Smooth Transitions: Animated state changes throughout the app
- Responsive Design: Adapts to different iPhone sizes
- Native Feel: Follows iOS Human Interface Guidelines
- Pull-to-Refresh: Native gesture support for content refresh
⚠️ Important: The current implementation includes the API token directly in the source code for demonstration purposes. For production:
- Use
.xcconfigfiles excluded from version control - Consider using a backend proxy to hide API tokens
- Store sensitive data in Keychain for additional security
- Never commit tokens to public repositories
- Search functionality by character name
- Favorite characters with Core Data persistence
- Filter by publisher (Marvel, DC, etc.)
- Filter by alignment (Good, Bad, Neutral)
- Share character cards
- Compare two characters side-by-side
- Support for iPad with adaptive layouts
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- SuperHero API for the comprehensive superhero database
- SuperHeroDB for character data and images
- Apple for SwiftUI framework
- The amazing comic book universes (Marvel, DC, and more) for endless inspiration
Matheus Abrahão - @yourusername
Project Link: https://github.com/yourusername/superhero-app
Data provided by SuperHero API. Character data from various comic book publishers.