Skip to content

Commit

Permalink
work_items: handle markdown comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sstasi95 committed Jun 25, 2024
1 parent 2656a10 commit e5fcd51
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/src/models/work_item_comments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Comment {
required this.createdDate,
required this.modifiedBy,
required this.modifiedDate,
required this.format,
});

factory Comment.fromJson(Map<String, dynamic> json) => Comment(
Expand All @@ -48,6 +49,7 @@ class Comment {
createdDate: DateTime.parse(json['createdDate']!.toString()).toLocal(),
modifiedBy: EdBy.fromJson(json['modifiedBy'] as Map<String, dynamic>),
modifiedDate: DateTime.parse(json['modifiedDate']!.toString()).toLocal(),
format: json['format'] as String,
);

final int workItemId;
Expand All @@ -58,6 +60,7 @@ class Comment {
final DateTime createdDate;
final EdBy modifiedBy;
final DateTime modifiedDate;
final String format;
}

class EdBy {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/models/work_item_updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,14 @@ class CommentItemUpdate extends ItemUpdate {
required this.id,
required this.text,
this.isEdited = false,
required this.format,
});

final int workItemId;
final int id;
final String text;
final bool isEdited;
final String format;
}

final class UpdateUser {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/screens/work_item_detail/base_work_item_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import 'package:azure_devops/src/widgets/work_item_type_icon.dart';
import 'package:collection/collection.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:html_editor_enhanced/html_editor.dart';
import 'package:open_filex/open_filex.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:visibility_detector/visibility_detector.dart';

part 'components_work_item_detail.dart';
Expand Down
21 changes: 17 additions & 4 deletions lib/src/screens/work_item_detail/components_work_item_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,23 @@ class _CommentWidget extends StatelessWidget {
const SizedBox(
height: 5,
),
HtmlWidget(
data: update.text,
padding: const EdgeInsets.all(3),
),
if (update.format == 'markdown')
Padding(
padding: const EdgeInsets.only(left: 8, bottom: 8, right: 8),
child: MarkdownBody(
data: update.text,
styleSheet:
MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(p: context.textTheme.labelMedium),
onTapLink: (_, url, ___) async {
if (await canLaunchUrlString(url!)) await launchUrlString(url);
},
),
)
else if (update.format == 'html')
HtmlWidget(
data: update.text,
padding: const EdgeInsets.all(3),
),
const SizedBox(
height: 4,
),
Expand Down
1 change: 1 addition & 0 deletions lib/src/services/azure_api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ class AzureApiServiceImpl with AppLogger implements AzureApiService {
workItemId: c.workItemId,
text: c.text,
isEdited: c.createdDate.isBefore(c.modifiedDate),
format: c.format,
),
),
...updates.where((u) => u.hasSupportedChanges).map(
Expand Down

0 comments on commit e5fcd51

Please sign in to comment.