Skip to content

Commit

Permalink
Added dynamic theme handling for search icons in records tab
Browse files Browse the repository at this point in the history
  • Loading branch information
andreped committed Sep 23, 2024
1 parent d2da557 commit 15e1f37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/core/search_delegate.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'theme.dart';

class ExerciseSearchDelegate extends SearchDelegate {
final List<Map<String, dynamic>> records;
Expand All @@ -13,9 +14,10 @@ class ExerciseSearchDelegate extends SearchDelegate {

@override
List<Widget> buildActions(BuildContext context) {
final ThemeData theme = Theme.of(context);
return [
IconButton(
icon: Icon(Icons.clear),
icon: Icon(Icons.clear, color: theme.iconTheme.color),
onPressed: () {
query = '';
},
Expand All @@ -25,8 +27,9 @@ class ExerciseSearchDelegate extends SearchDelegate {

@override
Widget buildLeading(BuildContext context) {
final ThemeData theme = Theme.of(context);
return IconButton(
icon: Icon(Icons.arrow_back),
icon: Icon(Icons.arrow_back, color: theme.iconTheme.color),
onPressed: () {
close(context, null);
},
Expand Down
7 changes: 4 additions & 3 deletions lib/widgets/records.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class _RecordsTabState extends State<RecordsTab> {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
final arrowColor = isDarkMode ? Colors.purple : null;
final textColor = isDarkMode ? Colors.white : Colors.black;
final ThemeData theme = Theme.of(context);

return Scaffold(
appBar: AppBar(
Expand All @@ -151,14 +152,14 @@ class _RecordsTabState extends State<RecordsTab> {
: Text('Records'),
leading: _isSearching
? IconButton(
icon: Icon(Icons.arrow_back),
icon: Icon(Icons.arrow_back, color: theme.iconTheme.color),
onPressed: _stopSearch,
)
: null,
actions: _isSearching
? [
IconButton(
icon: Icon(Icons.clear),
icon: Icon(Icons.clear, color: theme.iconTheme.color),
onPressed: () {
_searchController.clear();
_filterRecords('');
Expand All @@ -167,7 +168,7 @@ class _RecordsTabState extends State<RecordsTab> {
]
: [
IconButton(
icon: Icon(Icons.search),
icon: Icon(Icons.search, color: theme.iconTheme.color),
onPressed: _startSearch,
),
],
Expand Down

0 comments on commit 15e1f37

Please sign in to comment.