mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-11-20 11:48:01 -06:00
feat: add popular monospace fonts
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11
-1
@@ -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),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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