getSubtitle method
Implementation
TextSpan getSubtitle(BuildContext context) {
HelpdeskService service = Provider.of<HelpdeskService>(context);
Color color = getColor(data, service);
if (data is HelpdeskCategory) {
num count = data.sections.length;
String text = count.toString() + (count > 1 ? " sections" : " section");
return TextSpan(
text: text,
style: TextStyle(
fontSize: SizeProvider.instance.size(14),
fontWeight: FontWeight.w600,
color: color,
fontFamily: TextProvider.familyNunitoSans,
package: 'style'),
);
}
if (data is HelpdeskSection) {
num count = data.articles.length;
String text = count.toString() + (count > 1 ? " articles" : " article");
return TextSpan(
text: text,
style:
TextStyle(color: color, fontFamily: TextProvider.familyNunitoSans,
package: 'tiki_style',));
}
if (data is HelpdeskArticle) {
if (service.model.data is List<HelpdeskArticle> && service.model.section?.title != null ) {
return TextSpan(
text: "published in ",
style: TextStyle(color: color,
fontFamily: TextProvider.familyNunitoSans,
package: 'tiki_style',
),
children: [
TextSpan(
text: service.model.section!.title,
style: TextStyle(color: color,
fontFamily: TextProvider.familyNunitoSans,
package: 'tiki_style',
fontWeight: color == ColorProvider.greyFive
? FontWeight.bold
: FontWeight.normal),
)]
);
} else {
DateTime date = data.updatedAt;
String publishedDate = DateFormat.yMMMMd('en_US').format(date);
return TextSpan(
text: "published on $publishedDate",
style: TextStyle(color: color,
fontSize: SizeProvider.instance.height(15),
fontFamily: TextProvider.familyNunitoSans,
package: 'tiki_style',
fontWeight: color == ColorProvider.greySix
? FontWeight.w600
: FontWeight.normal),
);
}
}
return const TextSpan(text: '');
}