Skip to content

Commit 74be3f7

Browse files
committed
Mobile: full-width hero avatar at 45% screen height with name below
1 parent f4f90cc commit 74be3f7

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

lib/main.dart

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ class HomePage extends StatelessWidget {
3030
children: [
3131
Container(
3232
width: double.infinity,
33-
height: MediaQuery.of(context).size.height,
33+
height: isMobile ? null : MediaQuery.of(context).size.height,
3434
color: const Color(0xFF3A3A3A),
35-
padding: const EdgeInsets.symmetric(horizontal: 46, vertical: 46),
36-
alignment: isMobile ? Alignment.center : Alignment.centerLeft,
35+
padding: isMobile
36+
? EdgeInsets.zero
37+
: const EdgeInsets.symmetric(horizontal: 46, vertical: 46),
38+
alignment: isMobile ? null : Alignment.centerLeft,
3739
child: isMobile ? const _MobileHeader() : const _DesktopHeader(),
3840
),
3941
Container(
@@ -68,29 +70,30 @@ class _MobileHeader extends StatelessWidget {
6870
@override
6971
Widget build(BuildContext context) {
7072
final screenHeight = MediaQuery.of(context).size.height;
71-
final avatarRadius = screenHeight * 0.15;
7273

7374
return Column(
74-
mainAxisSize: MainAxisSize.min,
75-
crossAxisAlignment: CrossAxisAlignment.center,
75+
crossAxisAlignment: CrossAxisAlignment.start,
7676
children: [
77-
CircleAvatar(
78-
radius: avatarRadius,
79-
backgroundImage: const NetworkImage(
77+
SizedBox(
78+
width: double.infinity,
79+
height: screenHeight * 0.45,
80+
child: Image.network(
8081
'https://avatars.githubusercontent.com/will-ch-h',
82+
fit: BoxFit.cover,
8183
),
8284
),
83-
SizedBox(height: screenHeight * 0.04),
84-
const Text(
85-
'will-ch-h',
86-
style: TextStyle(
87-
color: Colors.white,
88-
fontSize: 32,
89-
fontWeight: FontWeight.bold,
90-
letterSpacing: 1.2,
85+
const Padding(
86+
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 20),
87+
child: Text(
88+
'will-ch-h',
89+
style: TextStyle(
90+
color: Colors.white,
91+
fontSize: 28,
92+
fontWeight: FontWeight.bold,
93+
letterSpacing: 1.2,
94+
),
9195
),
9296
),
93-
const SizedBox(height: 24),
9497
// information goes here
9598
],
9699
);

0 commit comments

Comments
 (0)