friend_health_data.dart 2.23 KB
import 'package:doublefeel_flutter/data/models/friend/friend_models.dart'
    as api_models;
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';

import 'friend_stress_state.dart';

class FriendHealthData {
  const FriendHealthData({
    required this.friendItem,
    this.userId,
    this.avatarUrl,
    required this.name,
    this.remark,
    required this.updatedAt,
    required this.sleepQualityScore,
    required this.steps,
    required this.stressState,
    this.stressValueText,
    this.isOnWatchFace = false,
  });

  final api_models.FriendItem friendItem;
  final int? userId;
  final String? avatarUrl;
  final String name;
  final String? remark;
  final String updatedAt;
  final int? sleepQualityScore;
  final String? steps;
  final FriendStressState stressState;
  final String? stressValueText;
  final bool isOnWatchFace;

  String get displayName {
    final value = remark?.trim();
    if (value == null || value.isEmpty) return name;
    return l10n.friendsRemarkedDisplayName(value, name);
  }

  FriendHealthData copyWith({
    api_models.FriendItem? friendItem,
    int? userId,
    String? avatarUrl,
    String? name,
    String? remark,
    String? updatedAt,
    int? sleepQualityScore,
    String? steps,
    FriendStressState? stressState,
    String? stressValueText,
    bool? isOnWatchFace,
  }) {
    return FriendHealthData(
      friendItem: friendItem ?? this.friendItem,
      userId: userId ?? this.userId,
      avatarUrl: avatarUrl ?? this.avatarUrl,
      name: name ?? this.name,
      remark: remark ?? this.remark,
      updatedAt: updatedAt ?? this.updatedAt,
      sleepQualityScore: sleepQualityScore ?? this.sleepQualityScore,
      steps: steps ?? this.steps,
      stressState: stressState ?? this.stressState,
      stressValueText: stressValueText ?? this.stressValueText,
      isOnWatchFace: isOnWatchFace ?? this.isOnWatchFace,
    );
  }
}

class SelfFriendHealthData {
  const SelfFriendHealthData({
    required this.updatedAt,
    required this.sleepQualityScore,
    required this.steps,
    required this.stressState,
    this.stressValueText,
  });

  final String updatedAt;
  final int? sleepQualityScore;
  final String? steps;
  final FriendStressState stressState;
  final String? stressValueText;
}