poc: floating app bar & translucent nav bar
This commit is contained in:
parent
48d30cfa20
commit
1313d0c845
7 changed files with 64 additions and 44 deletions
|
@ -10,17 +10,13 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
<!-- This keeps the window background of the activity showing
|
|
||||||
until Flutter renders its first frame. It can be removed if
|
|
||||||
there is no splash screen (such as the default splash screen
|
|
||||||
defined in @style/LaunchTheme). -->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||||
android:value="true" />
|
android:value="false" />
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
|
4
android/app/src/main/res/values-land/flags.xml
Normal file
4
android/app/src/main/res/values-land/flags.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<bool name="translucentNavBar">false</bool>
|
||||||
|
</resources>
|
4
android/app/src/main/res/values/flags.xml
Normal file
4
android/app/src/main/res/values/flags.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<bool name="translucentNavBar">true</bool>
|
||||||
|
</resources>
|
|
@ -1,8 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
<style name="AppTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
<!-- Show a splash screen on the activity. Automatically removed when
|
<item name="android:windowTranslucentNavigation">@bool/translucentNavBar</item> <!-- API19+, tinted background & request the SYSTEM_UI_FLAG_LAYOUT_STABLE and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN flags -->
|
||||||
Flutter draws its first frame -->
|
|
||||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
11
lib/common/fake_app_bar.dart
Normal file
11
lib/common/fake_app_bar.dart
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
class FakeAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SafeArea(child: SizedBox.shrink());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => Size.zero;
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:aves/common/fake_app_bar.dart';
|
||||||
import 'package:aves/model/image_fetcher.dart';
|
import 'package:aves/model/image_fetcher.dart';
|
||||||
import 'package:aves/thumbnail_collection.dart';
|
import 'package:aves/thumbnail_collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -14,18 +15,14 @@ class MyApp extends StatelessWidget {
|
||||||
title: 'Aves',
|
title: 'Aves',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
primarySwatch: Colors.blue,
|
accentColor: Colors.amberAccent,
|
||||||
),
|
),
|
||||||
home: HomePage(title: 'Home'),
|
home: HomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
HomePage({Key key, this.title}) : super(key: key);
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HomePageState createState() => _HomePageState();
|
_HomePageState createState() => _HomePageState();
|
||||||
}
|
}
|
||||||
|
@ -47,15 +44,21 @@ class _HomePageState extends State<HomePage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
debugPrint('MediaQuery.of(context).viewInsets.bottom=${MediaQuery.of(context).viewInsets.bottom}');
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.title),
|
return MediaQuery.removeViewInsets(
|
||||||
),
|
context: context,
|
||||||
|
// remove bottom view insets to paint underneath the translucent navigation bar
|
||||||
|
removeBottom: true,
|
||||||
|
child: Scaffold(
|
||||||
|
// fake app bar so that content is safe from status bar, even though we use a SliverAppBar
|
||||||
|
appBar: FakeAppBar(),
|
||||||
body: imageEntryList == null
|
body: imageEntryList == null
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
)
|
)
|
||||||
: ThumbnailCollection(imageEntryList),
|
: ThumbnailCollection(imageEntryList),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,12 @@ class ThumbnailCollection extends StatelessWidget {
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
slivers: sections.keys
|
slivers: [
|
||||||
.map((sectionKey) => SliverStickyHeader(
|
SliverAppBar(
|
||||||
|
title: Text('Aves - All'),
|
||||||
|
floating: true,
|
||||||
|
),
|
||||||
|
...sections.keys.map((sectionKey) => SliverStickyHeader(
|
||||||
header: SectionHeader(sectionKey),
|
header: SectionHeader(sectionKey),
|
||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
@ -62,7 +66,7 @@ class ThumbnailCollection extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue