getSubTitle function

String getSubTitle(
  1. LocationNotificationModel locationNotificationModel
)

Returns the subtitle for a location notification model

Implementation

String getSubTitle(LocationNotificationModel locationNotificationModel) {
  DateTime? to;
  String time;
  to = locationNotificationModel.to;
  if (to != null) {
    if (locationNotificationModel.to!.day > DateTime.now().day) {
      time =
          'until ${timeOfDayToString(TimeOfDay.fromDateTime(locationNotificationModel.to!))} tomorrow';
    } else {
      time =
          'until ${timeOfDayToString(TimeOfDay.fromDateTime(locationNotificationModel.to!))} today';
    }
  } else {
    time = '';
  }
  if (locationNotificationModel.key!.contains(MixedConstants.SHARE_LOCATION)) {
    return locationNotificationModel.atsignCreator ==
            AtLocationNotificationListener().currentAtSign
        ? 'Can see my location $time'
        : 'Can see their location $time';
  } else {
    // var _locationsharingFor =
    //     getLocationSharingForCreator(locationNotificationModel);

    // if ((_locationsharingFor != null) && (_locationsharingFor.to != null)) {
    //   time =
    //       'until ${timeOfDayToString(TimeOfDay.fromDateTime(_locationsharingFor.to!))} today';
    // } else {
    //   time = '';
    // }

    // return (_locationsharingFor != null && _locationsharingFor.isAccepted)
    //     ? (compareAtSign(locationNotificationModel.atsignCreator!,
    //             AtLocationNotificationListener().currentAtSign!)
    //         ? 'Sharing my location $time'
    //         : 'Sharing their location $time')
    //     : (compareAtSign(locationNotificationModel.atsignCreator!,
    //             AtLocationNotificationListener().currentAtSign!)
    //         ? 'Request Location received'
    //         : 'Request Location sent');

    ////////
    return locationNotificationModel.isAccepted
        ? (locationNotificationModel.atsignCreator ==
                AtLocationNotificationListener().currentAtSign
            ? 'Sharing my location $time'
            : 'Sharing their location $time')
        : (locationNotificationModel.atsignCreator ==
                AtLocationNotificationListener().currentAtSign
            ? 'Request Location received'
            : 'Request Location sent');
  }
}