Add padding to TwoPane usage
This commit is contained in:
Родитель
0c1c5fe8bc
Коммит
407fbac468
|
@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
|
|||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
ext.kotlin_version = '1.5.10'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
|
|
@ -18,6 +18,8 @@ class CompanionPane extends StatelessWidget {
|
|||
pane2: ToolsPane(),
|
||||
paneProportion: 0.7,
|
||||
direction: Axis.vertical,
|
||||
padding: EdgeInsets.only(
|
||||
top: kToolbarHeight + MediaQuery.of(context).padding.top),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -59,31 +61,29 @@ class LargeToolsPane extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight,
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
children: [
|
||||
Spacer(flex: 10),
|
||||
...tools
|
||||
.expand((e) => [
|
||||
ExpandedToolTile(tool: e),
|
||||
Spacer(flex: 1),
|
||||
])
|
||||
.toList(),
|
||||
Spacer(flex: 10),
|
||||
],
|
||||
),
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight,
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
children: [
|
||||
Spacer(flex: 10),
|
||||
...tools
|
||||
.expand((e) => [
|
||||
ExpandedToolTile(tool: e),
|
||||
Spacer(flex: 1),
|
||||
])
|
||||
.toList(),
|
||||
Spacer(flex: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ class _DualViewNotepadState extends State<DualViewNotepad> {
|
|||
child: Markdown(data: data),
|
||||
),
|
||||
panePriority: panePriority,
|
||||
padding: EdgeInsets.only(
|
||||
top: kToolbarHeight + MediaQuery.of(context).padding.top),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ class _DualViewRestaurantsState extends State<DualViewRestaurants> {
|
|||
singleScreen: singleScreen,
|
||||
),
|
||||
panePriority: panePriority,
|
||||
padding: EdgeInsets.only(top: kToolbarHeight + MediaQuery.of(context).padding.top),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,12 +35,30 @@ class _ExtendedCanvasState extends State<ExtendedCanvas> {
|
|||
selectedRestaurant = index;
|
||||
});
|
||||
if (index != null) {
|
||||
await showModalBottomSheet(context: context, builder: (context) {
|
||||
return RestaurantDetails(restaurant: restaurants[index]);
|
||||
}, anchorPoint: Offset(0.0, double.infinity));
|
||||
await showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestaurantDetails(restaurant: restaurants[index]);
|
||||
},
|
||||
anchorPoint: _roughLocationOnScreen(context, index),
|
||||
);
|
||||
setState(() {
|
||||
selectedRestaurant = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Restaurant latLong vary from -1 to 1 and we map that to coordinates on the
|
||||
/// screen.
|
||||
Offset _roughLocationOnScreen(BuildContext context, int index) {
|
||||
if ((MediaQuery.of(context).hinge?.bounds.size.aspectRatio ?? 0) > 1) {
|
||||
// When the hinge separates the screens top-bottom, we always use the
|
||||
// bottom screen.
|
||||
return Offset(0.0, 1000);
|
||||
}
|
||||
final restaurantLocation = restaurants[index].latLong;
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
return Offset((restaurantLocation.lat + 1) * screenSize.width / 2,
|
||||
(restaurantLocation.long + 1) * screenSize.height / 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:dual_screen/dual_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -83,6 +84,8 @@ class HingeAngle extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
top: kToolbarHeight + MediaQuery.of(context).padding.top),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -114,25 +117,15 @@ class HingeAngle extends StatelessWidget {
|
|||
}
|
||||
|
||||
String formatPosture(ui.DisplayFeatureState displayFeatureState) {
|
||||
final longForm = displayFeatureState.toString();
|
||||
if (longForm.length < 20) {
|
||||
return longForm;
|
||||
} else if (longForm.length < 27) {
|
||||
return longForm.substring(20);
|
||||
} else {
|
||||
return longForm.substring(27);
|
||||
switch (displayFeatureState) {
|
||||
case DisplayFeatureState.postureFlat:
|
||||
return 'Flat';
|
||||
case DisplayFeatureState.postureHalfOpened:
|
||||
return 'HalfOpened';
|
||||
case DisplayFeatureState.unknown:
|
||||
default:
|
||||
return 'unknown';
|
||||
}
|
||||
// switch (displayFeatureState) {
|
||||
// case DisplayFeatureState.unknown:
|
||||
// return 'unknown';
|
||||
// case DisplayFeatureState.postureFlat:
|
||||
// return 'Flat';
|
||||
// case DisplayFeatureState.postureHalfOpened:
|
||||
// return 'HalfOpened';
|
||||
// case DisplayFeatureState.postureFlipped:
|
||||
// return 'Flipped';
|
||||
// }
|
||||
// return 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ class _ListDetailState extends State<ListDetail> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool singleScreen = MediaQuery.of(context).hinge?.bounds?.top != 0.0;
|
||||
print('Single screen $singleScreen');
|
||||
return Theme(
|
||||
data: ThemeData.dark(),
|
||||
child: Scaffold(
|
||||
|
@ -42,9 +41,10 @@ class _ListDetailState extends State<ListDetail> {
|
|||
),
|
||||
pane2:
|
||||
DetailsPane(image: selected == null ? null : images[selected!]),
|
||||
panePriority: singleScreen
|
||||
? TwoPanePriority.pane1
|
||||
: TwoPanePriority.both,
|
||||
panePriority:
|
||||
singleScreen ? TwoPanePriority.pane1 : TwoPanePriority.both,
|
||||
padding: EdgeInsets.only(
|
||||
top: kToolbarHeight + MediaQuery.of(context).padding.top),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -98,45 +98,43 @@ class SamplesList extends StatelessWidget {
|
|||
title: Text('Samples list'),
|
||||
),
|
||||
body: TwoPane(
|
||||
pane1: Container(
|
||||
child: ListView.builder(
|
||||
itemCount: sampleCatalogue.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ListTile(
|
||||
title: Text(sampleCatalogue[index].title),
|
||||
subtitle: Text(sampleCatalogue[index].subtitle),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(sampleCatalogue[index].route);
|
||||
},
|
||||
trailing: PopupMenuButton(
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
value: 1,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text("View Code")),
|
||||
SizedBox(width: 16),
|
||||
Icon(Icons.open_in_new),
|
||||
],
|
||||
),
|
||||
pane1: ListView.builder(
|
||||
itemCount: sampleCatalogue.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ListTile(
|
||||
title: Text(sampleCatalogue[index].title),
|
||||
subtitle: Text(sampleCatalogue[index].subtitle),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(sampleCatalogue[index].route);
|
||||
},
|
||||
trailing: PopupMenuButton(
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
value: 1,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text("View Code")),
|
||||
SizedBox(width: 16),
|
||||
Icon(Icons.open_in_new),
|
||||
],
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (_) {
|
||||
launch(sampleCatalogue[index].link);
|
||||
},
|
||||
child: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
padding: EdgeInsets.symmetric(vertical: 4.0),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(Icons.more_vert),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (_) {
|
||||
launch(sampleCatalogue[index].link);
|
||||
},
|
||||
child: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
padding: EdgeInsets.symmetric(vertical: 4.0),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(Icons.more_vert),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
pane2: Container(),
|
||||
panePriority: MediaQuery.of(context).hinge == null
|
||||
|
|
20
pubspec.lock
20
pubspec.lock
|
@ -21,7 +21,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.5.0"
|
||||
version: "2.8.2"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -42,7 +42,7 @@ packages:
|
|||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -77,7 +77,7 @@ packages:
|
|||
path: "../dual_screen"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0"
|
||||
version: "1.0.0+3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -204,14 +204,14 @@ packages:
|
|||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.10"
|
||||
version: "0.12.11"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.7.0"
|
||||
mgrs_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -311,9 +311,11 @@ packages:
|
|||
source: hosted
|
||||
version: "2.1.5"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
path: "/Users/andreidiaconu/work/flutter/engine/src/out/host_debug_unopt/gen/dart-pkg/sky_engine"
|
||||
relative: false
|
||||
source: path
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
|
@ -356,7 +358,7 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.19"
|
||||
version: "0.4.3"
|
||||
transparent_image:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -9,8 +9,6 @@ import 'dart:ui' as ui;
|
|||
///
|
||||
/// Clears any mock handlers that were configured for [HINGE_ANGLE_CHANNEL].
|
||||
void mockHingeAngleStream(List<double> multipleSensorValues) {
|
||||
// const EventChannel HINGE_ANGLE_CHANNEL =
|
||||
// EventChannel('com.microsoft.flutterdualscreen/hinge_angle');
|
||||
const StandardMethodCodec standardMethod = StandardMethodCodec();
|
||||
String channelName = 'com.microsoft.flutterdualscreen/hinge_angle';
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче