tzktSample
is a SwiftUI application developed in Xcode, designed to fetch and display lists of blockchain blocks and transactions using the tzkt.io REST API. This project showcases SwiftUI views, ViewModel architecture, and network request handling in Swift.
- Fetch and display a list of blockchain blocks.
- Fetch and display transactions for a specific block.
- Pull-to-refresh functionality in lists.
- Dependency injection for network services, enhancing testability.
- Comprehensive unit tests for ViewModels and network services.
All the version reported below are what the app was built and tested with, forward or backward compatibility should not be a problem but is not guaranteed. Please report any incompatibilities.
- iOS 16.4+ (should be good down to around 15.0)
- Xcode 14.0+
- Swift 5.0+
Clone the repository, and open the project in Xcode:
git clone https://github.com/Requieem/tzktSample_IOS.git
cd tzktSample
open tzktSample.xcodeproj
The application consists of two main views:
-
BlockListView: Displays a list of blockchain blocks. Each block can be tapped to view its transactions.
-
TransactionListView: Shows transactions for the selected block.
Pull down on either list to refresh the content.
This project follows the MVVM (Model-View-ViewModel) architecture:
- Model: Represents the data structure (e.g.,
Block
,Transaction
). - View: SwiftUI views for user interface (e.g.,
BlockListView
,TransactionListView
). - ViewModel: Logic layer that handles data fetching and processing (e.g.,
VM_BlockTable
,VM_TransactionTable
).
Network requests are handled by APIService
, which is abstracted behind URLSessionProtocol
to enable mocking for unit tests.
Unit tests are written using XCTest framework. MockURLSession
and MockAPIService
are used to simulate network responses.
This is the current structure of the project:
tzktSample/
│
├── Fonts/
│ └── Urbanist/
│
├── tzktSample/
│ ├── Utility/
│ │ ├── CustomDateFormatter.swift
│ │ ├── CustomJsonDecoder.swift
│ │ └── APIService.swift
│ │
│ ├── Protocols/
│ │ └── URLSessionProtocol.swift
│ │
│ ├── ViewModel/
│ │ ├── VM_BlockTable.swift
│ │ └── VM_TransactionTable.swift
│ │
│ ├── View/
│ │ ├── BlockTable.swift
│ │ ├── TransactionTable.swift
│ │ └── Header.swift
│ │
│ └── Model/
│ └── tzktSampleApp/
│
├── Assets/
│ └── Preview Content/
│
└── tzktSampleTests/
├── Mocks/
│ ├── MockURLSession.swift
│ ├── MockDecodable.swift
│ └── MockAPIService.swift
│
├── APIServiceTests.swift
├── VM_BlockTableTests.swift
└── VM_TransactionTableTests.swift
During the development of tzktSample
, several external tools were utilized to aid in the design, testing, and validation of the application:
Postman was used for testing and interacting with the tzkt.io REST API. This helped in understanding the API responses and structuring the network layer of the app accordingly.
To explore and test the API endpoints used in this project, you can use the following Postman collection:
The user interface design and prototyping were conducted using Figma. Figma enabled quick iteration over the app's UI/UX design, ensuring a user-friendly experience.
You can view the Figma designs for this project here: TZKT Figma Design
This project is licensed under the GNU GPLv3.0 License - see the LICENSE file for details.
This README.md file was structured following this awesome template!