Meshtastic-Apple/Meshtastic/Enums/ChannelRoles.swift
Blake McAnally 58da532d32 Extract the generated protobufs into its own Swift package
This change modifies the process for generating and integrating the Meshtastic protobufs into the client application.

* The generated Swift code is now in a local SPM package `MeshtasticProtobufs`
* An Xcode Workspace file `Meshtastic.xcworkspace` was created to more easily manage the new build targets.
* The code generation script for the protos was modified to generate the Swift code into the new location.
* The README.md was updated to reflect these changes.

NOTE: After merging this PR, do not open the project file `Meshtastic.xcodeproj`. You must use the workspace `Meshtastic.xcworkspace`

Extracting out the generated protobuf code into its own library enables several opportunities for the project. This is just a first step, but with some more modularization, a standalone Apple Watch app or other targets starts to become a little bit more achievable to implement.

After extracting the protobufs into a Swift package, I validate these changes by building and running the Meshtastic app to an iPhone 15 Pro Max, and tried changing some settings on a local node. I then messaged back and forth using two local nodes connected to two different iOS devices.
2024-06-28 11:11:01 -05:00

41 lines
763 B
Swift

//
// ChannelRoles.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 9/21/22.
//
import Foundation
import MeshtasticProtobufs
// Default of 0 is Client
enum ChannelRoles: Int, CaseIterable, Identifiable {
case disabled = 0
case primary = 1
case secondary = 2
var id: Int { self.rawValue }
var description: String {
switch self {
case .disabled:
return "channel.role.disabled".localized
case .primary:
return "channel.role.primary".localized
case .secondary:
return "channel.role.secondary".localized
}
}
func protoEnumValue() -> Channel.Role {
switch self {
case .disabled:
return Channel.Role.disabled
case .primary:
return Channel.Role.primary
case .secondary:
return Channel.Role.secondary
}
}
}