Update samples to work with new TwoPane parameter signature

This commit is contained in:
Andrei Diaconu 2022-02-17 22:04:49 +02:00
Родитель 26acfb30d8
Коммит c15c3d1b55
8 изменённых файлов: 68 добавлений и 69 удалений

Просмотреть файл

@ -15,11 +15,11 @@ class CompanionPane extends StatelessWidget {
title: Text('Companion Pane'),
),
body: TwoPane(
pane1: PreviewPane(),
pane2: ToolsPane(),
startPane: PreviewPane(),
endPane: ToolsPane(),
paneProportion: 0.7,
direction: singleScreen ? Axis.vertical : Axis.horizontal,
padding: EdgeInsets.only(
inset: EdgeInsets.only(
top: kToolbarHeight + MediaQuery.of(context).padding.top),
),
),

Просмотреть файл

@ -22,7 +22,7 @@ class _DualViewNotepadState extends State<DualViewNotepad> {
bool singleScreen = MediaQuery.of(context).hinge == null && MediaQuery.of(context).size.width < 1000;
var panePriority = TwoPanePriority.both;
if (singleScreen) {
panePriority = editing ? TwoPanePriority.pane1 : TwoPanePriority.pane2;
panePriority = editing ? TwoPanePriority.start : TwoPanePriority.end;
}
return Scaffold(
appBar: AppBar(
@ -41,7 +41,7 @@ class _DualViewNotepadState extends State<DualViewNotepad> {
],
),
body: TwoPane(
pane1: DraftSavedMessage(
startPane: DraftSavedMessage(
child: PaneDecorations(
header: Text('Editor'),
contentColor: Colors.white,
@ -62,14 +62,14 @@ class _DualViewNotepadState extends State<DualViewNotepad> {
),
),
),
pane2: PaneDecorations(
endPane: PaneDecorations(
header: Text('Preview'),
contentColor: Colors.transparent,
headerColor: Colors.green[200]!,
child: Markdown(data: data),
),
panePriority: panePriority,
padding: EdgeInsets.only(
inset: EdgeInsets.only(
top: kToolbarHeight + MediaQuery.of(context).padding.top),
),
);

Просмотреть файл

@ -23,7 +23,7 @@ class _DualViewRestaurantsState extends State<DualViewRestaurants> {
bool singleScreen = MediaQuery.of(context).hinge == null && MediaQuery.of(context).size.width < 1000;
var panePriority = TwoPanePriority.both;
if (singleScreen) {
panePriority = showList ? TwoPanePriority.pane1 : TwoPanePriority.pane2;
panePriority = showList ? TwoPanePriority.start : TwoPanePriority.end;
}
Widget restaurantList = ListPane(
@ -69,11 +69,11 @@ class _DualViewRestaurantsState extends State<DualViewRestaurants> {
],
),
body: TwoPane(
pane1: restaurantList,
pane2: restaurantMap,
startPane: restaurantList,
endPane: restaurantMap,
panePriority: panePriority,
paneProportion: 0.4,
padding: EdgeInsets.only(top: kToolbarHeight + MediaQuery.of(context).padding.top),
inset: EdgeInsets.only(top: kToolbarHeight + MediaQuery.of(context).padding.top),
),
);
}

Просмотреть файл

@ -212,10 +212,10 @@ class RestaurantScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(title: Text(restaurant.name)),
body: TwoPane(
pane1: RestaurantDetails(restaurant: restaurant),
pane2: RestaurantDetailsSecondScreen(restaurant: restaurant),
startPane: RestaurantDetails(restaurant: restaurant),
endPane: RestaurantDetailsSecondScreen(restaurant: restaurant),
panePriority: MediaQuery.of(context).hinge == null
? TwoPanePriority.pane1
? TwoPanePriority.start
: TwoPanePriority.both,
),
);

Просмотреть файл

@ -21,7 +21,7 @@ class HingeAngle extends StatelessWidget {
? Axis.horizontal
: Axis.vertical,
paneProportion: orientation == Orientation.landscape ? 0.6 : 0.4,
pane1: Container(
startPane: Container(
padding: const EdgeInsets.all(16.0),
alignment: Alignment.center,
child: Table(
@ -69,7 +69,7 @@ class HingeAngle extends StatelessWidget {
],
),
),
pane2: Padding(
endPane: Padding(
padding: const EdgeInsets.all(16.0),
child: StreamBuilder<double>(
stream: DualScreenInfo.hingeAngleEvents,
@ -84,7 +84,7 @@ class HingeAngle extends StatelessWidget {
},
),
),
padding: EdgeInsets.only(
inset: EdgeInsets.only(
top: kToolbarHeight + MediaQuery.of(context).padding.top),
),
),

Просмотреть файл

@ -15,7 +15,7 @@ class _ListDetailState extends State<ListDetail> {
@override
Widget build(BuildContext context) {
bool singleScreen = MediaQuery.of(context).hinge?.bounds?.top != 0.0 && MediaQuery.of(context).size.width < 1000;
bool singleScreen = MediaQuery.of(context).hinge == null && MediaQuery.of(context).size.width < 1000;
Widget list = ListPane(
images: images,
@ -43,12 +43,11 @@ class _ListDetailState extends State<ListDetail> {
title: Text('List Detail'),
),
body: TwoPane(
pane1: list,
pane2: details,
panePriority:
singleScreen ? TwoPanePriority.pane1 : TwoPanePriority.both,
startPane: list,
endPane: details,
panePriority: TwoPanePriority.start,
paneProportion: 0.3,
padding: EdgeInsets.only(
inset: EdgeInsets.only(
top: kToolbarHeight + MediaQuery.of(context).padding.top),
),
),
@ -113,46 +112,49 @@ class DetailsPane extends StatelessWidget {
@override
Widget build(BuildContext context) {
return image == null
? Center(child: Text('Pick an image from the grid.'))
: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Image.asset(image!),
),
Padding(
padding: const EdgeInsets.only(left: 32.0),
child: Row(children: [
Expanded(
child: Center(
child: ListTile(
leading: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Icon(Icons.camera, size: 30),
),
title: Text('Camera'),
subtitle: Text('f/2.0 2.5mm ISO 520'),
),
),
),
Expanded(
child: ListTile(
leading: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Icon(Icons.camera_alt, size: 30),
),
title: Text('Device'),
subtitle: Text('Surface Duo'),
),
)
]),
),
],
return Container(
color: Theme.of(context).colorScheme.surface,
child: image == null
? Center(child: Text('Pick an image from the grid.'))
: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Image.asset(image!),
),
);
Padding(
padding: const EdgeInsets.only(left: 32.0),
child: Row(children: [
Expanded(
child: Center(
child: ListTile(
leading: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Icon(Icons.camera, size: 30),
),
title: Text('Camera'),
subtitle: Text('f/2.0 2.5mm ISO 520'),
),
),
),
Expanded(
child: ListTile(
leading: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Icon(Icons.camera_alt, size: 30),
),
title: Text('Device'),
subtitle: Text('Surface Duo'),
),
)
]),
),
],
),
),
);
}
}

Просмотреть файл

@ -5,7 +5,6 @@ import 'package:dual_screen_samples/dual_view_restaurants/dual_view_restaurants.
import 'package:dual_screen_samples/extended_canvas/extended_canvas.dart';
import 'package:dual_screen_samples/hinge_angle/hinge_angle.dart';
import 'package:dual_screen_samples/list_detail/list_detail.dart';
import 'package:dual_screen_samples/mediaquery_hinge.dart';
import 'package:dual_screen_samples/two_page/two_page.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
@ -108,7 +107,7 @@ class SamplesList extends StatelessWidget {
title: Text('Samples list'),
),
body: TwoPane(
pane1: ListView.builder(
startPane: ListView.builder(
itemCount: sampleCatalogue.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
@ -146,10 +145,8 @@ class SamplesList extends StatelessWidget {
);
},
),
pane2: Container(),
panePriority: MediaQuery.of(context).hinge == null
? TwoPanePriority.pane1
: TwoPanePriority.both,
endPane: Container(),
panePriority: TwoPanePriority.start,
),
);
}

Просмотреть файл

@ -447,7 +447,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
win32:
dependency: transitive
description: