2019-09-15 11:36:09 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_highlight/flutter_highlight.dart';
|
|
|
|
import 'package:flutter_highlight/theme_map.dart';
|
|
|
|
import 'package:git_touch/models/code.dart';
|
2019-09-29 09:02:06 +02:00
|
|
|
import 'package:git_touch/models/theme.dart';
|
2019-09-25 11:06:36 +02:00
|
|
|
import 'package:git_touch/scaffolds/single.dart';
|
2019-10-02 09:39:47 +02:00
|
|
|
import 'package:git_touch/utils/utils.dart';
|
2019-09-15 11:36:09 +02:00
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
2019-09-29 09:02:06 +02:00
|
|
|
import 'package:git_touch/widgets/table_view.dart';
|
2019-09-15 11:36:09 +02:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2019-09-28 18:25:14 +02:00
|
|
|
class CodeThemeScreen extends StatelessWidget {
|
2019-09-15 11:36:09 +02:00
|
|
|
final String code;
|
|
|
|
final String language;
|
|
|
|
|
2019-09-28 18:25:14 +02:00
|
|
|
CodeThemeScreen(this.code, this.language);
|
2019-09-15 11:36:09 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var codeProvider = Provider.of<CodeModel>(context);
|
2019-09-29 09:02:06 +02:00
|
|
|
var themeProvider = Provider.of<ThemeModel>(context);
|
2019-09-15 11:36:09 +02:00
|
|
|
|
2019-09-25 11:06:36 +02:00
|
|
|
return SingleScaffold(
|
2019-09-15 11:36:09 +02:00
|
|
|
title: AppBarTitle('Code theme'),
|
2019-09-25 11:06:36 +02:00
|
|
|
body: Column(
|
2019-09-25 08:24:20 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: <Widget>[
|
2019-09-29 09:02:06 +02:00
|
|
|
TableView(
|
2019-09-25 08:24:20 +02:00
|
|
|
items: [
|
2019-09-29 09:02:06 +02:00
|
|
|
TableViewItem(
|
|
|
|
text: Text('Syntax Highlighting'),
|
|
|
|
rightWidget: Text(codeProvider.theme),
|
|
|
|
onTap: () {
|
|
|
|
themeProvider.showPicker(
|
|
|
|
context,
|
|
|
|
PickerGroupItem(
|
|
|
|
value: codeProvider.theme,
|
|
|
|
items: CodeModel.themes
|
|
|
|
.map((v) => PickerItem(v, text: v))
|
|
|
|
.toList(),
|
|
|
|
onChange: (value) {
|
|
|
|
Provider.of<CodeModel>(context).setTheme(value);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2019-09-25 08:24:20 +02:00
|
|
|
},
|
|
|
|
),
|
2019-09-29 09:02:06 +02:00
|
|
|
TableViewItem(
|
|
|
|
text: Text('Font Size'),
|
|
|
|
rightWidget: Text(codeProvider.fontSize.toString()),
|
|
|
|
onTap: () {
|
|
|
|
themeProvider.showPicker(
|
|
|
|
context,
|
|
|
|
PickerGroupItem(
|
|
|
|
value: codeProvider.fontSize.toString(),
|
|
|
|
items: CodeModel.fontSizes
|
|
|
|
.map((v) =>
|
|
|
|
PickerItem(v.toString(), text: v.toString()))
|
|
|
|
.toList(),
|
|
|
|
onChange: (value) {
|
|
|
|
Provider.of<CodeModel>(context)
|
|
|
|
.setFontSize(int.tryParse(value) ?? 16);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2019-09-25 08:24:20 +02:00
|
|
|
},
|
|
|
|
),
|
2019-09-29 09:02:06 +02:00
|
|
|
TableViewItem(
|
|
|
|
text: Text('Font Family'),
|
|
|
|
rightWidget: Text(codeProvider.fontFamily),
|
|
|
|
onTap: () {
|
|
|
|
themeProvider.showPicker(
|
|
|
|
context,
|
|
|
|
PickerGroupItem(
|
|
|
|
value: codeProvider.fontFamily,
|
|
|
|
items: CodeModel.fontFamilies
|
|
|
|
.map((v) => PickerItem(v, text: v))
|
|
|
|
.toList(),
|
|
|
|
onChange: (String value) {
|
|
|
|
Provider.of<CodeModel>(context).setFontFamily(value);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2019-09-25 08:24:20 +02:00
|
|
|
},
|
2019-09-15 11:36:09 +02:00
|
|
|
),
|
2019-09-25 08:24:20 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: HighlightView(
|
|
|
|
code,
|
|
|
|
language: language,
|
|
|
|
theme: themeMap[codeProvider.theme],
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: codeProvider.fontSize.toDouble(),
|
|
|
|
fontFamily: codeProvider.fontFamilyUsed,
|
|
|
|
),
|
2019-10-02 10:09:54 +02:00
|
|
|
padding: CommonStyle.padding,
|
2019-09-25 08:24:20 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2019-09-15 11:36:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|