Skip to content

Commit

Permalink
NavBar顶部高度改为实时获取,防止最开始的时候拿不到
Browse files Browse the repository at this point in the history
  • Loading branch information
Luozf12345 committed Jan 30, 2024
1 parent bdfc43f commit c233b0b
Showing 4 changed files with 79 additions and 38 deletions.
42 changes: 42 additions & 0 deletions tdesign-component/example/lib/component_test/test_navbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

void main(){
runApp( MaterialApp(
home: Builder(builder: (context){
return Scaffold(
// appBar: TDNavBar(),
appBar: PreferredSize(
preferredSize: Size(MediaQuery.of(context).size.width,MediaQuery.of(context).size.height + MediaQuery.of(context).padding.top),
child: Padding(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
child: TDNavBar(
useDefaultBack: false,
// screenAdaptation: false,
centerTitle: false,
titleMargin: 0,
titleWidget: TDSearchBar(
needCancel: false,
autoHeight: true,
padding: const EdgeInsets.fromLTRB(0, 2, 0, 2),
placeHolder: '搜索预设文案',
mediumStyle: true,
style: TDSearchStyle.round,
onTextChanged: (String text) {
print('input:$text');
},
),
rightBarItems: [
TDNavBarItem(icon: TDIcons.home,iconSize: 24),
TDNavBarItem(icon: TDIcons.ellipsis,iconSize: 24)
]
),
),
),
body: Center(
child: TDText("测试文案"),
),
);
},),
));
}
36 changes: 18 additions & 18 deletions tdesign-component/example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
url: "https://pub.dev"
source: hosted
version: "2.11.0"
version: "2.10.0"
boolean_selector:
dependency: transitive
description:
@@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.2.1"
clock:
dependency: transitive
description:
@@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.0"
cupertino_icons:
dependency: "direct main"
description:
@@ -127,10 +127,10 @@ packages:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "0.6.5"
lints:
dependency: transitive
description:
@@ -151,10 +151,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.13"
material_color_utilities:
dependency: transitive
description:
@@ -167,18 +167,18 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@@ -222,7 +222,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "0.1.2"
term_glyph:
dependency: transitive
description:
@@ -235,10 +235,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.4.16"
typed_data:
dependency: transitive
description:
@@ -256,5 +256,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=3.0.0-0 <4.0.0"
dart: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
5 changes: 2 additions & 3 deletions tdesign-component/lib/src/components/navbar/td_nav_bar.dart
Original file line number Diff line number Diff line change
@@ -185,8 +185,6 @@ class _TDNavBarState extends State<TDNavBar> {
);
}

late final top = MediaQuery.of(context).padding.top;

Widget _getNavbarChild(){
final Widget toolbar = NavigationToolbar(
leading: _buildTitleBarItems(true),
@@ -215,13 +213,14 @@ class _TDNavBarState extends State<TDNavBar> {
bcc = bcc.withOpacity(widget.opacity);
}

var paddingTop = widget.screenAdaptation ? top : 0.0;
var paddingTop = widget.screenAdaptation ? MediaQuery.of(context).padding.top : 0.0;
var padding = widget.padding ??
EdgeInsets.symmetric(
horizontal: TDTheme.of(context).spacer16,
vertical: TDTheme.of(context).spacer4,
);

print("screenAdaptation:${widget.screenAdaptation}, paddingTop:$paddingTop");
return Container(
color: bcc,
height: widget.height + paddingTop,
34 changes: 17 additions & 17 deletions tdesign-component/pubspec.lock
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
url: "https://pub.dev"
source: hosted
version: "2.11.0"
version: "2.10.0"
boolean_selector:
dependency: transitive
description:
@@ -21,10 +21,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.2.1"
clock:
dependency: transitive
description:
@@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.0"
fake_async:
dependency: transitive
description:
@@ -87,10 +87,10 @@ packages:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "0.6.5"
lints:
dependency: transitive
description:
@@ -103,10 +103,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.13"
material_color_utilities:
dependency: transitive
description:
@@ -119,18 +119,18 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@@ -180,10 +180,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.4.16"
vector_math:
dependency: transitive
description:
@@ -193,5 +193,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=3.0.0-0 <4.0.0"
dart: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"

0 comments on commit c233b0b

Please sign in to comment.