Skip to content

Commit 03906da

Browse files
(fix) replaced watch icon on medium size screens with app icon
1 parent e6ed4aa commit 03906da

1 file changed

Lines changed: 42 additions & 9 deletions

File tree

open_wearable/lib/widgets/home_page.dart

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const int _sensorsIndex = 2;
1414
const int _sectionCount = 5;
1515

1616
const double _largeScreenBreakpoint = 960;
17+
const String _appIconAsset =
18+
'android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png';
1719

1820
class HomePage extends StatefulWidget {
1921
final int initialSectionIndex;
@@ -159,15 +161,7 @@ class _HomePageState extends State<HomePage> {
159161
extended: useExtendedRail,
160162
leading: Padding(
161163
padding: const EdgeInsets.symmetric(vertical: 20),
162-
child: useExtendedRail
163-
? Text(
164-
'OpenWearable',
165-
style: Theme.of(context).textTheme.titleMedium,
166-
)
167-
: Icon(
168-
Icons.watch,
169-
color: Theme.of(context).colorScheme.primary,
170-
),
164+
child: _AppRailLogo(extended: useExtendedRail),
171165
),
172166
destinations: _destinations
173167
.map(
@@ -251,3 +245,42 @@ class _HomeDestination {
251245
required this.selectedIcon,
252246
});
253247
}
248+
249+
class _AppRailLogo extends StatelessWidget {
250+
final bool extended;
251+
252+
const _AppRailLogo({
253+
required this.extended,
254+
});
255+
256+
@override
257+
Widget build(BuildContext context) {
258+
final icon = ClipRRect(
259+
borderRadius: BorderRadius.circular(8),
260+
child: Image.asset(
261+
_appIconAsset,
262+
width: 32,
263+
height: 32,
264+
fit: BoxFit.cover,
265+
filterQuality: FilterQuality.medium,
266+
semanticLabel: 'OpenWearable app icon',
267+
),
268+
);
269+
270+
if (!extended) {
271+
return icon;
272+
}
273+
274+
return Row(
275+
mainAxisSize: MainAxisSize.min,
276+
children: [
277+
icon,
278+
const SizedBox(width: 12),
279+
Text(
280+
'OpenWearable',
281+
style: Theme.of(context).textTheme.titleMedium,
282+
),
283+
],
284+
);
285+
}
286+
}

0 commit comments

Comments
 (0)