Fix some more code style
This commit is contained in:
parent
fe5c5a4cce
commit
cfe5a65380
|
@ -137,7 +137,6 @@ linter:
|
||||||
- unnecessary_await_in_return
|
- unnecessary_await_in_return
|
||||||
- unnecessary_brace_in_string_interps
|
- unnecessary_brace_in_string_interps
|
||||||
- unnecessary_const
|
- unnecessary_const
|
||||||
- unnecessary_constructor_name
|
|
||||||
- unnecessary_getters_setters
|
- unnecessary_getters_setters
|
||||||
- unnecessary_new
|
- unnecessary_new
|
||||||
- unnecessary_null_aware_assignments
|
- unnecessary_null_aware_assignments
|
||||||
|
|
|
@ -4,24 +4,22 @@ part of 'theme_bloc.dart';
|
||||||
abstract class ThemeState {
|
abstract class ThemeState {
|
||||||
final bool prefsAreLoaded;
|
final bool prefsAreLoaded;
|
||||||
|
|
||||||
const ThemeState(this.prefsAreLoaded);
|
const ThemeState({required this.prefsAreLoaded});
|
||||||
|
|
||||||
AppTheme get theme;
|
AppTheme get theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LightThemeState extends ThemeState {
|
class LightThemeState extends ThemeState {
|
||||||
final bool prefsAreLoaded;
|
const LightThemeState({bool prefsAreLoaded = false})
|
||||||
|
: super(prefsAreLoaded: prefsAreLoaded);
|
||||||
const LightThemeState({this.prefsAreLoaded = false}) : super(prefsAreLoaded);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
AppTheme get theme => LightTheme();
|
AppTheme get theme => LightTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DarkThemeState extends ThemeState {
|
class DarkThemeState extends ThemeState {
|
||||||
final bool prefsAreLoaded;
|
const DarkThemeState({bool prefsAreLoaded = false})
|
||||||
|
: super(prefsAreLoaded: prefsAreLoaded);
|
||||||
const DarkThemeState({this.prefsAreLoaded = false}) : super(prefsAreLoaded);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
AppTheme get theme => DarkTheme();
|
AppTheme get theme => DarkTheme();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:sembast/sembast.dart';
|
import 'package:sembast/sembast.dart';
|
||||||
import 'package:sembast/timestamp.dart';
|
|
||||||
|
|
||||||
import './kanji_query.dart';
|
import './kanji_query.dart';
|
||||||
import './word_query.dart';
|
import './word_query.dart';
|
||||||
|
|
|
@ -50,7 +50,9 @@ class ColorSet {
|
||||||
MaterialColor createMaterialColor(Color color) {
|
MaterialColor createMaterialColor(Color color) {
|
||||||
final List<double> strengths = [.05];
|
final List<double> strengths = [.05];
|
||||||
final swatch = <int, Color>{};
|
final swatch = <int, Color>{};
|
||||||
final int r = color.red, g = color.green, b = color.blue;
|
final int r = color.red;
|
||||||
|
final int g = color.green;
|
||||||
|
final int b = color.blue;
|
||||||
|
|
||||||
for (int i = 1; i < 10; i++) {
|
for (int i = 1; i < 10; i++) {
|
||||||
strengths.add(0.1 * i);
|
strengths.add(0.1 * i);
|
||||||
|
|
|
@ -12,13 +12,13 @@ Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
return MaterialPageRoute(builder: (_) => const Home());
|
return MaterialPageRoute(builder: (_) => const Home());
|
||||||
|
|
||||||
case '/search':
|
case '/search':
|
||||||
final searchTerm = args as String;
|
final searchTerm = args! as String;
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => SearchResultsPage(searchTerm: searchTerm),
|
builder: (_) => SearchResultsPage(searchTerm: searchTerm),
|
||||||
);
|
);
|
||||||
|
|
||||||
case '/kanjiSearch':
|
case '/kanjiSearch':
|
||||||
final searchTerm = args as String;
|
final searchTerm = args! as String;
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm),
|
builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm),
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,26 +54,26 @@ class KanjiSearchItem extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Slidable(
|
return Slidable(
|
||||||
child: SearchItem(
|
actionPane: const SlidableScrollActionPane(),
|
||||||
onTap: () {
|
secondaryActions: const [
|
||||||
Navigator.pushNamed(context, '/kanjiSearch', arguments: this.result.kanji);
|
|
||||||
},
|
|
||||||
time: timestamp,
|
|
||||||
search: _KanjiBox(result.kanji),
|
|
||||||
),
|
|
||||||
actionPane: SlidableScrollActionPane(),
|
|
||||||
secondaryActions: [
|
|
||||||
IconSlideAction(
|
IconSlideAction(
|
||||||
caption: "Favourite",
|
caption: 'Favourite',
|
||||||
color: Colors.yellow,
|
color: Colors.yellow,
|
||||||
icon: Icons.star,
|
icon: Icons.star,
|
||||||
),
|
),
|
||||||
IconSlideAction(
|
IconSlideAction(
|
||||||
caption: "Delete",
|
caption: 'Delete',
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
icon: Icons.delete,
|
icon: Icons.delete,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
child: SearchItem(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushNamed(context, '/kanjiSearch', arguments: result.kanji);
|
||||||
|
},
|
||||||
|
time: timestamp,
|
||||||
|
search: _KanjiBox(result.kanji),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ class KanjiSearchBar extends StatefulWidget {
|
||||||
const KanjiSearchBar({this.onChanged, Key? key}) : super(key: key);
|
const KanjiSearchBar({this.onChanged, Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
KanjiSearchBarState createState() => KanjiSearchBarState(this.onChanged);
|
KanjiSearchBarState createState() => KanjiSearchBarState();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TextFieldButton { clear, paste }
|
enum TextFieldButton { clear, paste }
|
||||||
|
@ -15,9 +15,6 @@ enum TextFieldButton { clear, paste }
|
||||||
class KanjiSearchBarState extends State<KanjiSearchBar> {
|
class KanjiSearchBarState extends State<KanjiSearchBar> {
|
||||||
final TextEditingController textController = TextEditingController();
|
final TextEditingController textController = TextEditingController();
|
||||||
TextFieldButton button = TextFieldButton.paste;
|
TextFieldButton button = TextFieldButton.paste;
|
||||||
final Function(String)? onChanged;
|
|
||||||
|
|
||||||
KanjiSearchBarState(this.onChanged);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -25,7 +22,7 @@ class KanjiSearchBarState extends State<KanjiSearchBar> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void runOnChanged() {
|
void runOnChanged() {
|
||||||
if (onChanged != null) onChanged!(textController.text);
|
if (widget.onChanged != null) widget.onChanged!(textController.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearText() {
|
void clearText() {
|
||||||
|
@ -56,7 +53,7 @@ class KanjiSearchBarState extends State<KanjiSearchBar> {
|
||||||
return TextField(
|
return TextField(
|
||||||
controller: textController,
|
controller: textController,
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
if (onChanged != null) onChanged!(text);
|
if (widget.onChanged != null) widget.onChanged!(text);
|
||||||
},
|
},
|
||||||
onSubmitted: (_) => {},
|
onSubmitted: (_) => {},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|
|
@ -2,25 +2,27 @@ import 'package:flutter/material.dart';
|
||||||
import './badge.dart';
|
import './badge.dart';
|
||||||
|
|
||||||
class WKBadge extends StatelessWidget {
|
class WKBadge extends StatelessWidget {
|
||||||
final String wkLevel;
|
final String level;
|
||||||
|
|
||||||
const WKBadge(this.wkLevel);
|
const WKBadge({
|
||||||
|
required this.level,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
String _extractWkLevel(String wkRaw) {
|
String _extractWkLevel(String wkRaw) {
|
||||||
// return jlptRaw.isNotEmpty ? jlptRaw.substring(5).toUpperCase() : '';
|
return wkRaw.isNotEmpty ? 'W${wkRaw.substring(8)}' : '';
|
||||||
return wkRaw.isNotEmpty ? 'W' + wkRaw.substring(8) : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Badge(
|
return Badge(
|
||||||
|
color: level.isNotEmpty ? Colors.red : Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
_extractWkLevel(this.wkLevel),
|
_extractWkLevel(level),
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
color: this.wkLevel.isNotEmpty ? Colors.red : Colors.transparent
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@ class SearchResultCard extends StatelessWidget {
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
WKBadge(
|
WKBadge(
|
||||||
result.tags.firstWhere(
|
level: result.tags.firstWhere(
|
||||||
(tag) => tag.contains('wanikani'),
|
(tag) => tag.contains('wanikani'),
|
||||||
orElse: () => '',
|
orElse: () => '',
|
||||||
),
|
),
|
||||||
|
|
|
@ -8,6 +8,6 @@ class KanjiView extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return KanjiSearchBody();
|
return const KanjiSearchBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue