Skip to content

Commit 953061f

Browse files
author
Ritam Chakraborty
committed
Add finishing touches
1 parent d828b2e commit 953061f

File tree

13 files changed

+31
-21
lines changed

13 files changed

+31
-21
lines changed
5.21 KB
Loading
2.71 KB
Loading
7.61 KB
Loading
14.6 KB
Loading
21.6 KB
Loading

lib/main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class MyApp extends StatelessWidget {
3030
return BlocBuilder<ThemeBloc, ThemeMode>(
3131
builder: (BuildContext context, ThemeMode themeMode) {
3232
return MaterialApp(
33-
title: 'Flutter Demo',
33+
title: 'Sorting Visualizer',
34+
debugShowCheckedModeBanner: false,
3435
theme: ThemeData(
36+
brightness: Brightness.light,
3537
primarySwatch: Colors.blue,
3638
iconTheme: IconThemeData(
3739
color: Colors.grey.shade800,

lib/pages/home_page.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:sortingvisualizer/bloc/theme_bloc/theme_bloc.dart';
88
import 'package:sortingvisualizer/data/constants.dart';
99
import 'package:sortingvisualizer/pages/sorting_page.dart';
1010
import 'package:sortingvisualizer/provider/sorting_provider.dart';
11-
import 'package:sortingvisualizer/widgets/theme_changing_icon.dart';
11+
import 'package:sortingvisualizer/widgets/theme_change_icon.dart';
1212

1313
class HomePage extends StatefulWidget {
1414
@override
@@ -57,6 +57,7 @@ class _HomePageState extends State<HomePage> {
5757
cubit: themeBloc,
5858
builder: (BuildContext context, ThemeMode themeMode) {
5959
Widget icon = ThemeChangingIcon(themeMode: themeMode);
60+
String themeChangerToolTip = themeMode == ThemeMode.light ? "Change to Dark Theme" : "Change to Light Theme";
6061

6162
return Material(
6263
child: Scaffold(
@@ -65,7 +66,11 @@ class _HomePageState extends State<HomePage> {
6566
elevation: 0.0,
6667
centerTitle: true,
6768
actions: [
68-
IconButton(icon: icon, onPressed: themeBloc.changeTheme),
69+
IconButton(
70+
icon: icon,
71+
onPressed: themeBloc.changeTheme,
72+
tooltip: themeChangerToolTip,
73+
),
6974
],
7075
title: Text(
7176
"Sorting Visualizer",
@@ -97,7 +102,7 @@ class _HomePageState extends State<HomePage> {
97102
context,
98103
MaterialPageRoute(
99104
builder: (BuildContext context) =>
100-
ChangeNotifierProvider<SortingProvider>.value(
105+
ChangeNotifierProvider<SortingProvider>.value(
101106
value: SortingProvider(size: bars, array: list),
102107
child: SortingPage(),
103108
),
@@ -124,9 +129,7 @@ class _HomePageState extends State<HomePage> {
124129
Text(
125130
"Enter number of bars",
126131
style: TextStyle(
127-
color: Theme
128-
.of(context)
129-
.hintColor,
132+
color: Theme.of(context).hintColor,
130133
),
131134
),
132135
Text(
@@ -139,18 +142,14 @@ class _HomePageState extends State<HomePage> {
139142
Container(
140143
margin: const EdgeInsets.all(8.0),
141144
width: double.infinity,
142-
color: Theme
143-
.of(context)
144-
.accentColor,
145+
color: Theme.of(context).accentColor,
145146
height: 2,
146147
),
147148
Text(
148149
error,
149150
textAlign: TextAlign.center,
150151
style: TextStyle(
151-
color: Theme
152-
.of(context)
153-
.errorColor,
152+
color: Theme.of(context).errorColor,
154153
),
155154
)
156155
],

lib/pages/sorting_page.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:sortingvisualizer/utils/utils.dart';
1111
import 'package:sortingvisualizer/widgets/bar.dart';
1212
import 'package:sortingvisualizer/widgets/rounded_button.dart';
1313
import 'package:sortingvisualizer/widgets/sorting_dropdown.dart';
14-
import 'package:sortingvisualizer/widgets/theme_changing_icon.dart';
14+
import 'package:sortingvisualizer/widgets/theme_change_icon.dart';
1515

1616
class SortingPage extends StatelessWidget {
1717
@override
@@ -110,6 +110,9 @@ class SortingPage extends StatelessWidget {
110110
return BlocBuilder<ThemeBloc, ThemeMode>(
111111
builder: (BuildContext context, ThemeMode themeMode) {
112112
Widget icon = ThemeChangingIcon(themeMode: themeMode);
113+
String themeChangerToolTip = themeMode == ThemeMode.light
114+
? "Change to Dark Theme"
115+
: "Change to Light Theme";
113116

114117
return Material(
115118
child: Scaffold(
@@ -123,13 +126,15 @@ class SortingPage extends StatelessWidget {
123126
),
124127
actions: [
125128
IconButton(
126-
icon: icon,
127-
onPressed: isSorting
128-
? null
129-
: () {
130-
sortingProvider.reset();
131-
themeBloc.changeTheme();
132-
}),
129+
icon: icon,
130+
onPressed: isSorting
131+
? null
132+
: () {
133+
sortingProvider.reset();
134+
themeBloc.changeTheme();
135+
},
136+
tooltip: themeChangerToolTip,
137+
),
133138
],
134139
),
135140
body: SafeArea(

lib/widgets/sorting_dropdown.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class SortingDropdown extends StatelessWidget {
2020
onPressed: null,
2121
disabledBorderColor: Theme.of(context).accentColor,
2222
shape: SHAPE,
23+
borderSide: BorderSide(
24+
width: 4,
25+
style: BorderStyle.solid,
26+
color: Theme.of(context).accentColor),
2327
child: DropdownButtonHideUnderline(
2428
child: DropdownButton<String>(
2529
onChanged: _onChanged,
File renamed without changes.

0 commit comments

Comments
 (0)