git-touch-android-ios-app/lib/widgets/files_item.dart

62 lines
1.7 KiB
Dart
Raw Normal View History

2022-09-24 20:46:37 +02:00
import 'package:antd_mobile/antd_mobile.dart';
import 'package:flutter/foundation.dart';
2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
2020-04-30 18:04:24 +02:00
import 'package:flutter_highlight/flutter_highlight.dart';
2022-09-17 14:35:45 +02:00
import 'package:flutter_highlight/theme_map.dart';
2020-04-30 18:04:24 +02:00
import 'package:git_touch/models/code.dart';
2022-09-17 14:35:45 +02:00
import 'package:git_touch/models/theme.dart';
2020-04-30 18:04:24 +02:00
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
class FilesItem extends StatelessWidget {
2022-09-06 18:28:12 +02:00
const FilesItem({
2021-05-16 09:16:35 +02:00
required this.filename,
required this.status,
required this.deletions,
required this.additions,
required this.patch,
2020-04-30 18:04:24 +02:00
});
2022-09-21 18:28:21 +02:00
final String? filename;
final String? status;
final int? additions;
final int? deletions;
final String? patch;
2020-04-30 18:04:24 +02:00
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
final codeProvider = Provider.of<CodeModel>(context);
2022-10-06 09:55:35 +02:00
return AntCollapse(
2022-10-26 18:41:57 +02:00
activeKey: const {},
2022-10-06 09:55:35 +02:00
onChange: (_) {
// TODO: set active
},
panels: [
AntCollapsePanel(
key: '',
title: Text(
filename!,
style: TextStyle(
color: AntTheme.of(context).colorPrimary,
fontSize: 18,
fontWeight: FontWeight.w600,
),
2020-04-30 18:04:24 +02:00
),
2022-10-06 09:55:35 +02:00
child: SingleChildScrollView(
2020-04-30 18:04:24 +02:00
scrollDirection: Axis.horizontal,
child: HighlightView(
2021-05-16 09:16:35 +02:00
patch!,
2020-04-30 18:04:24 +02:00
language: 'diff',
padding: CommonStyle.padding,
theme: themeMap[theme.brightness == Brightness.dark
? codeProvider.themeDark
2021-05-16 09:16:35 +02:00
: codeProvider.theme]!,
2021-07-20 08:33:34 +02:00
textStyle: codeProvider.fontStyle,
2020-04-30 18:04:24 +02:00
),
),
2022-10-06 09:55:35 +02:00
),
],
2020-04-30 18:04:24 +02:00
);
}
}