Skip to content

Commit

Permalink
Merge pull request #4 from Pippo8291/main
Browse files Browse the repository at this point in the history
Enhance task_output_view and workflow
  • Loading branch information
gsmlg authored Mar 11, 2024
2 parents 675e112 + 243b7aa commit 140d626
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 29 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1

- name: 🛤 Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: '11'
Expand All @@ -29,3 +29,9 @@ jobs:
run: |
flutter pub get
flutter build apk --release --split-per-abi --no-pub
- name: Upload APK
uses: actions/[email protected]
with:
name: release-apk
path: build/app/outputs/apk/
84 changes: 57 additions & 27 deletions lib/components/task_output_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ import 'package:semaphore/adaptive/icon.dart';
import 'package:semaphore/adaptive/icon_button.dart';
import 'package:semaphore/components/status_chip.dart';
import 'package:semaphore/state/projects/task.dart';
import 'package:flutter/material.dart';

class TaskOutputView extends ConsumerWidget {
final int id;

const TaskOutputView({super.key, required this.id});

static const Map<String, Color> colorMap = {
'30': Colors.black,
'31': Colors.red,
'32': Colors.green,
'33': Colors.yellow,
'34': Colors.blue,
'35': Colors.purple,
'36': Colors.cyan,
'37': Colors.white
};

@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context);
Expand Down Expand Up @@ -66,34 +78,52 @@ class TaskOutputView extends ConsumerWidget {
),
const SizedBox(height: 12),
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: taskOutput
.map((line) => SelectableText.rich(TextSpan(
text: line.time?.toLocal().toString() ?? '',
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
color: isDark
? Colors.lightGreenAccent
: Colors.lightGreen),
),
children: <InlineSpan>[
const TextSpan(text: '\t'),
TextSpan(
text: line.output?.replaceAll(
RegExp(r'\u001b\[([0-9;]+)m'),
'') ??
'',
style: GoogleFonts.robotoMono(
textStyle: TextStyle(color: textColor),
),
),
])))
.toList(),
),
),
child: SingleChildScrollView(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: taskOutput.map((line) {
List<InlineSpan> coloredSegments = [];
RegExp colorRegex = RegExp(r'\u001b\[[0-9];([0-9]+)m');
List<String> segments = line.output?.split('\u001b[0m') ?? [];

for (String segment in segments) {
Color specificColor = textColor;

// Check if the segment matches the color code pattern
if (colorRegex.hasMatch(segment)) {
String colorCode = colorRegex.firstMatch(segment)?.group(1) ?? '';
specificColor = colorMap[colorCode] ?? textColor;
}

coloredSegments.add(TextSpan(
text: segment.replaceAll(colorRegex, ''), // Remove color codes
style: GoogleFonts.robotoMono(
textStyle: TextStyle(color: specificColor),
),
));
}

return SelectableText.rich(
TextSpan(
text: line.time?.toLocal().toString() ?? '',
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
color: isDark ? Colors.lightGreenAccent : Colors.lightGreen,
),
),
children: <InlineSpan>[
const TextSpan(text: '\t'),
...coloredSegments,
],
),
);
}).toList(),
),
),
),
),
],
);
},
Expand Down

0 comments on commit 140d626

Please sign in to comment.