Skip to content

Commit

Permalink
Added symbols icon and fraction key to second page (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkuschka committed Jan 5, 2022
1 parent 150d5f2 commit 400e0a5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 4 deletions.
5 changes: 5 additions & 0 deletions math_keyboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.3

* Added new symbols icon for functions button.
* Added fraction button to second keyboard page.

## 0.1.2

* Bumped `flutter_math_fork`.
Expand Down
Binary file added math_keyboard/fonts/CustomKeyIcons.ttf
Binary file not shown.
17 changes: 17 additions & 0 deletions math_keyboard/lib/src/custom_key_icons/custom_key_icons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// Flutter icons CustomKeyIcons
/// Copyright (C) 2022 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
import 'package:flutter/widgets.dart';

/// A collection of custom key icons.
class CustomKeyIcons {
CustomKeyIcons._();

static const _kFontFam = 'CustomKeyIcons';
static const String? _kFontPkg = 'math_keyboard';

/// Key icon used for indicating multiple symbols.
static const IconData key_symbols =
IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
6 changes: 6 additions & 0 deletions math_keyboard/lib/src/foundation/keyboard_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ const _subtractButton = BasicKeyboardButtonConfig(
/// Keyboard showing extended functionality.
final functionKeyboard = [
[
const BasicKeyboardButtonConfig(
label: r'\frac{\Box}{\Box}',
value: r'\frac',
args: [TeXArg.braces, TeXArg.braces],
asTex: true,
),
const BasicKeyboardButtonConfig(
label: r'\Box^2',
value: '^2',
Expand Down
6 changes: 5 additions & 1 deletion math_keyboard/lib/src/widgets/math_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_math_fork/flutter_math.dart';
import 'package:math_keyboard/src/custom_key_icons/custom_key_icons.dart';
import 'package:math_keyboard/src/foundation/keyboard_button.dart';
import 'package:math_keyboard/src/widgets/decimal_separator.dart';
import 'package:math_keyboard/src/widgets/keyboard_button.dart';
Expand Down Expand Up @@ -341,7 +342,10 @@ class _Buttons extends StatelessWidget {
else if (config is PageButtonConfig)
_BasicButton(
flex: config.flex,
label: controller.secondPage ? '123' : 'f(x)',
icon: controller.secondPage
? null
: CustomKeyIcons.key_symbols,
label: controller.secondPage ? '123' : null,
onTap: controller.togglePage,
highlightLevel: 1,
)
Expand Down
8 changes: 7 additions & 1 deletion math_keyboard/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: math_keyboard
description: >-2
Math expression editing using an on-screen software keyboard or physical keyboard input in a
typeset input field in Flutter.
version: 0.1.2
version: 0.1.3
homepage: https://github.com/simpleclub/math_keyboard/tree/main/math_keyboard

environment:
Expand All @@ -26,3 +26,9 @@ dev_dependencies:
sdk: flutter

pedantic: ^1.11.0

flutter:
fonts:
- family: CustomKeyIcons
fonts:
- asset: fonts/CustomKeyIcons.ttf
7 changes: 5 additions & 2 deletions math_keyboard_demo/lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ class _DemoAppState extends State<DemoApp> {
title: appTitle,
theme: ThemeData(
brightness: _darkMode ? Brightness.dark : Brightness.light,
primarySwatch: Colors.amber,
accentColor: Colors.amberAccent,
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.amber,
).copyWith(
secondary: Colors.amberAccent,
),
),
home: DemoScaffold(
onToggleBrightness: () {
Expand Down

0 comments on commit 400e0a5

Please sign in to comment.