mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-05-10 23:54:00 -05:00
feat: add popular monospace fonts
This commit is contained in:
BIN
fonts/FiraCode-Bold.ttf
Normal file
BIN
fonts/FiraCode-Bold.ttf
Normal file
Binary file not shown.
BIN
fonts/FiraCode-Regular.ttf
Normal file
BIN
fonts/FiraCode-Regular.ttf
Normal file
Binary file not shown.
BIN
fonts/Inconsolata-Bold.ttf
Normal file
BIN
fonts/Inconsolata-Bold.ttf
Normal file
Binary file not shown.
BIN
fonts/Inconsolata-Regular.ttf
Normal file
BIN
fonts/Inconsolata-Regular.ttf
Normal file
Binary file not shown.
BIN
fonts/PTMono-Regular.ttf
Normal file
BIN
fonts/PTMono-Regular.ttf
Normal file
Binary file not shown.
BIN
fonts/SourceCodePro-Bold.ttf
Normal file
BIN
fonts/SourceCodePro-Bold.ttf
Normal file
Binary file not shown.
BIN
fonts/SourceCodePro-BoldItalic.ttf
Normal file
BIN
fonts/SourceCodePro-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
fonts/SourceCodePro-Regular.ttf
Normal file
BIN
fonts/SourceCodePro-Regular.ttf
Normal file
Binary file not shown.
BIN
fonts/SourceCodePro-RegularItalic.ttf
Normal file
BIN
fonts/SourceCodePro-RegularItalic.ttf
Normal file
Binary file not shown.
BIN
fonts/UbuntuMono-Bold.ttf
Normal file
BIN
fonts/UbuntuMono-Bold.ttf
Normal file
Binary file not shown.
BIN
fonts/UbuntuMono-BoldItalic.ttf
Normal file
BIN
fonts/UbuntuMono-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
fonts/UbuntuMono-Regular.ttf
Normal file
BIN
fonts/UbuntuMono-Regular.ttf
Normal file
Binary file not shown.
BIN
fonts/UbuntuMono-RegularItalic.ttf
Normal file
BIN
fonts/UbuntuMono-RegularItalic.ttf
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_highlight/theme_map.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class CodeModel with ChangeNotifier {
|
||||
@@ -9,7 +10,14 @@ class CodeModel with ChangeNotifier {
|
||||
|
||||
static var themes = themeMap.keys.toList();
|
||||
static const fontSizes = [12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
static const fontFamilies = ['System'];
|
||||
static const fontFamilies = [
|
||||
'System',
|
||||
'Fira Code',
|
||||
'Inconsolata',
|
||||
'PT Mono',
|
||||
'Source Code Pro',
|
||||
'Ubuntu Mono'
|
||||
];
|
||||
|
||||
String _theme = 'github';
|
||||
int _fontSize = 14;
|
||||
@@ -18,6 +26,8 @@ class CodeModel with ChangeNotifier {
|
||||
String get theme => _theme;
|
||||
int get fontSize => _fontSize;
|
||||
String get fontFamily => _fontFamily;
|
||||
String get fontFamilyUsed =>
|
||||
_fontFamily == 'System' ? monospaceFont : _fontFamily;
|
||||
|
||||
init() async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
@@ -79,7 +79,22 @@ class CodeSettingsScreen extends StatelessWidget {
|
||||
text: Text('Font Family'),
|
||||
rightWidget: Text(codeProvider.fontFamily.toString()),
|
||||
onTap: () {
|
||||
// TODO:
|
||||
Provider.of<ThemeModel>(context).showPicker(
|
||||
context,
|
||||
children:
|
||||
CodeModel.fontFamilies.map((k) => Text(k)).toList(),
|
||||
initialItem: CodeModel.fontFamilies
|
||||
.indexOf(codeProvider.fontFamily),
|
||||
onSelectedItemChanged: (int value) {
|
||||
if (_themeDebounce?.isActive ?? false)
|
||||
_themeDebounce.cancel();
|
||||
_themeDebounce =
|
||||
Timer(const Duration(milliseconds: 500), () {
|
||||
Provider.of<CodeModel>(context)
|
||||
.setFontFamily(CodeModel.fontFamilies[value]);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -92,7 +107,7 @@ class CodeSettingsScreen extends StatelessWidget {
|
||||
theme: themeMap[codeProvider.theme],
|
||||
textStyle: TextStyle(
|
||||
fontSize: codeProvider.fontSize.toDouble(),
|
||||
fontFamily: monospaceFont,
|
||||
fontFamily: codeProvider.fontFamilyUsed,
|
||||
),
|
||||
padding: const EdgeInsets.all(10),
|
||||
),
|
||||
|
||||
@@ -135,7 +135,7 @@ class ObjectScreen extends StatelessWidget {
|
||||
padding: EdgeInsets.all(10),
|
||||
textStyle: TextStyle(
|
||||
fontSize: codeProvider.fontSize.toDouble(),
|
||||
fontFamily: monospaceFont),
|
||||
fontFamily: codeProvider.fontFamilyUsed),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
34
pubspec.yaml
34
pubspec.yaml
@@ -58,3 +58,37 @@ flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- images/
|
||||
fonts:
|
||||
- family: Fira Code
|
||||
fonts:
|
||||
- asset: fonts/FiraCode-Regular.ttf
|
||||
- asset: fonts/FiraCode-Bold.ttf
|
||||
weight: 700
|
||||
- family: Inconsolata
|
||||
fonts:
|
||||
- asset: fonts/Inconsolata-Regular.ttf
|
||||
- asset: fonts/Inconsolata-Bold.ttf
|
||||
weight: 700
|
||||
- family: PT Mono
|
||||
fonts:
|
||||
- asset: fonts/PTMono-Regular.ttf
|
||||
- family: Source Code Pro
|
||||
fonts:
|
||||
- asset: fonts/SourceCodePro-Regular.ttf
|
||||
- asset: fonts/SourceCodePro-RegularItalic.ttf
|
||||
style: italic
|
||||
- asset: fonts/SourceCodePro-Bold.ttf
|
||||
weight: 700
|
||||
- asset: fonts/SourceCodePro-BoldItalic.ttf
|
||||
style: italic
|
||||
weight: 700
|
||||
- family: Ubuntu Mono
|
||||
fonts:
|
||||
- asset: fonts/UbuntuMono-Regular.ttf
|
||||
- asset: fonts/UbuntuMono-RegularItalic.ttf
|
||||
style: italic
|
||||
- asset: fonts/UbuntuMono-Bold.ttf
|
||||
weight: 700
|
||||
- asset: fonts/UbuntuMono-BoldItalic.ttf
|
||||
style: italic
|
||||
weight: 700
|
||||
|
||||
Reference in New Issue
Block a user