mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-24 06:53:46 +00:00
[ios] replase ints/doubles with string for track stats in ios
to pass already formatted by the core values instead of formatting them later using the same core formatters Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
f8996feb88
commit
2861d9db2a
@@ -4,14 +4,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TrackInfo : NSObject
|
||||
|
||||
@property (nonatomic, readonly) double distance;
|
||||
@property (nonatomic, readonly) double duration;
|
||||
@property (nonatomic, readonly) NSUInteger ascent;
|
||||
@property (nonatomic, readonly) NSUInteger descent;
|
||||
@property (nonatomic, readonly) NSUInteger maxElevation;
|
||||
@property (nonatomic, readonly) NSUInteger minElevation;
|
||||
@property (nonatomic, readonly) NSString * distance;
|
||||
@property (nonatomic, readonly) NSString * duration;
|
||||
@property (nonatomic, readonly) NSString * ascent;
|
||||
@property (nonatomic, readonly) NSString * descent;
|
||||
@property (nonatomic, readonly) NSString * maxElevation;
|
||||
@property (nonatomic, readonly) NSString * minElevation;
|
||||
|
||||
- (BOOL)hasElevationInfo;
|
||||
@property (nonatomic, readonly) BOOL hasElevationInfo;
|
||||
|
||||
+ (TrackInfo *)emptyInfo;
|
||||
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
#import "TrackInfo+Core.h"
|
||||
#import "AltitudeFormatter.h"
|
||||
#import "DistanceFormatter.h"
|
||||
#import "DurationFormatter.h"
|
||||
#import "StringUtils.h"
|
||||
|
||||
@implementation TrackInfo
|
||||
|
||||
- (BOOL)hasElevationInfo {
|
||||
return _ascent != 0 || _descent != 0 || _maxElevation != 0 || _minElevation != 0;
|
||||
}
|
||||
|
||||
+ (TrackInfo *)emptyInfo {
|
||||
return [[TrackInfo alloc] init];
|
||||
}
|
||||
@@ -19,12 +13,16 @@
|
||||
|
||||
- (instancetype)initWithTrackStatistics:(TrackStatistics const &)statistics {
|
||||
if (self = [super init]) {
|
||||
_distance = statistics.m_length;
|
||||
_duration = statistics.m_duration;
|
||||
_ascent = statistics.m_ascent;
|
||||
_descent = statistics.m_descent;
|
||||
_maxElevation = statistics.m_maxElevation;
|
||||
_minElevation = statistics.m_minElevation;
|
||||
_distance = ToNSString(statistics.GetFormattedLength());
|
||||
_duration = ToNSString(statistics.GetFormattedDuration());
|
||||
_ascent = ToNSString(statistics.GetFormattedAscent());
|
||||
_descent = ToNSString(statistics.GetFormattedDescent());
|
||||
_maxElevation = ToNSString(statistics.GetFormattedMaxElevation());
|
||||
_minElevation = ToNSString(statistics.GetFormattedMinElevation());
|
||||
_hasElevationInfo = statistics.m_ascent != 0 ||
|
||||
statistics.m_descent != 0 ||
|
||||
statistics.m_maxElevation != 0 ||
|
||||
statistics.m_minElevation != 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -48,19 +48,12 @@ extension TrackRecordingLiveActivityManager: TrackRecordingActivityManager {
|
||||
|
||||
private extension TrackRecordingLiveActivityAttributes.ContentState {
|
||||
init(trackInfo: TrackInfo) {
|
||||
let distance = DistanceFormatter.distanceString(fromMeters: trackInfo.distance)
|
||||
let duration = DurationFormatter.durationString(from: trackInfo.duration)
|
||||
let maxElevation = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.maxElevation))
|
||||
let minElevation = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.minElevation))
|
||||
let ascent = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.ascent))
|
||||
let descent = AltitudeFormatter.altitudeString(fromMeters: Double(trackInfo.descent))
|
||||
|
||||
self.distance = StatisticsViewModel(key: "", value: distance)
|
||||
self.duration = StatisticsViewModel(key: "", value: duration)
|
||||
self.maxElevation = StatisticsViewModel(key: L("elevation_profile_max_elevation"), value: maxElevation)
|
||||
self.minElevation = StatisticsViewModel(key: L("elevation_profile_min_elevation"), value: minElevation)
|
||||
self.ascent = StatisticsViewModel(key: L("elevation_profile_ascent"), value: ascent)
|
||||
self.descent = StatisticsViewModel(key: L("elevation_profile_descent"), value: descent)
|
||||
self.distance = StatisticsViewModel(key: "", value: trackInfo.distance)
|
||||
self.duration = StatisticsViewModel(key: "", value: trackInfo.duration)
|
||||
self.maxElevation = StatisticsViewModel(key: L("elevation_profile_max_elevation"), value: trackInfo.maxElevation)
|
||||
self.minElevation = StatisticsViewModel(key: L("elevation_profile_min_elevation"), value: trackInfo.minElevation)
|
||||
self.ascent = StatisticsViewModel(key: L("elevation_profile_ascent"), value: trackInfo.ascent)
|
||||
self.descent = StatisticsViewModel(key: L("elevation_profile_descent"), value: trackInfo.descent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ protocol ElevationProfileViewControllerDelegate: AnyObject {
|
||||
|
||||
fileprivate struct DescriptionsViewModel {
|
||||
let title: String
|
||||
let value: UInt
|
||||
let value: String
|
||||
let imageName: String
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ extension ElevationProfilePresenter {
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(cell: ElevationProfileDescriptionCell.self, indexPath: indexPath)
|
||||
let model = descriptionModels[indexPath.row]
|
||||
cell.configure(subtitle: model.title, value: formatter.yAxisString(from: Double(model.value)), imageName: model.imageName)
|
||||
cell.configure(subtitle: model.title, value: model.value, imageName: model.imageName)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class PlacePageTrackLayout: IPlacePageLayout {
|
||||
}()
|
||||
|
||||
lazy var elevationMapViewController: ElevationProfileViewController? = {
|
||||
guard trackData.trackInfo.hasElevationInfo(),
|
||||
guard trackData.trackInfo.hasElevationInfo,
|
||||
let elevationProfileData = trackData.elevationProfileData else {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user