From 21ab2b449e32070377e1fb7eeea18f34ca83309d Mon Sep 17 00:00:00 2001 From: DenserMeerkat Date: Fri, 28 Jun 2024 11:56:52 +0530 Subject: [PATCH] fix: Material theme deprecations --- lib/consts.dart | 2 +- .../common_widgets/editor_title_actions.dart | 4 +- lib/screens/common_widgets/envfield_cell.dart | 2 +- .../common_widgets/sidebar_filter.dart | 2 +- lib/screens/dashboard.dart | 2 +- .../envvar/editor_pane/secrets_pane.dart | 2 +- .../envvar/editor_pane/variables_pane.dart | 2 +- .../request_pane/request_body.dart | 95 +++++++++---------- .../request_pane/request_form_data.dart | 4 - .../request_pane/request_headers.dart | 4 - .../request_pane/request_params.dart | 4 - .../home_page/editor_pane/url_card.dart | 5 +- lib/screens/mobile/widgets/page_base.dart | 4 +- lib/widgets/card_request_details.dart | 4 +- lib/widgets/card_sidebar_environment.dart | 3 +- lib/widgets/card_sidebar_request.dart | 2 +- lib/widgets/checkbox.dart | 8 +- lib/widgets/codegen_previewer.dart | 3 +- lib/widgets/editor.dart | 2 +- lib/widgets/editor_json.dart | 2 +- lib/widgets/field_cell.dart | 2 +- lib/widgets/field_cell_obscurable.dart | 2 +- lib/widgets/field_header.dart | 2 +- lib/widgets/field_raw.dart | 2 + lib/widgets/json_previewer.dart | 6 +- lib/widgets/response_widgets.dart | 5 +- lib/widgets/splitview_dashboard.dart | 2 +- lib/widgets/splitview_drawer.dart | 2 +- lib/widgets/splitview_equal.dart | 2 +- lib/widgets/tables.dart | 2 +- 30 files changed, 88 insertions(+), 95 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index ad5a4129..1310bde4 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -26,7 +26,7 @@ final kIsAndroid = !kIsWeb && Platform.isAndroid; final kIsMobile = !kIsWeb && (Platform.isIOS || Platform.isAndroid); final kColorTransparentState = - MaterialStateProperty.all(Colors.transparent); + WidgetStateProperty.all(Colors.transparent); const kColorTransparent = Colors.transparent; const kColorWhite = Colors.white; const kColorBlack = Colors.black; diff --git a/lib/screens/common_widgets/editor_title_actions.dart b/lib/screens/common_widgets/editor_title_actions.dart index a142a345..51d69798 100644 --- a/lib/screens/common_widgets/editor_title_actions.dart +++ b/lib/screens/common_widgets/editor_title_actions.dart @@ -70,8 +70,8 @@ class EditorTitleActions extends StatelessWidget { message: tooltip, child: IconButton( style: ButtonStyle( - padding: MaterialStateProperty.all(const EdgeInsets.all(0) + padding), - shape: MaterialStateProperty.all(const ContinuousRectangleBorder()), + padding: WidgetStateProperty.all(const EdgeInsets.all(0) + padding), + shape: WidgetStateProperty.all(const ContinuousRectangleBorder()), ), onPressed: onPressed, icon: Icon( diff --git a/lib/screens/common_widgets/envfield_cell.dart b/lib/screens/common_widgets/envfield_cell.dart index 532c9379..a2593af6 100644 --- a/lib/screens/common_widgets/envfield_cell.dart +++ b/lib/screens/common_widgets/envfield_cell.dart @@ -44,7 +44,7 @@ class EnvCellField extends StatelessWidget { ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( - color: clrScheme.surfaceVariant, + color: clrScheme.surfaceContainerHighest, ), ), ), diff --git a/lib/screens/common_widgets/sidebar_filter.dart b/lib/screens/common_widgets/sidebar_filter.dart index 478159b4..ad99bebf 100644 --- a/lib/screens/common_widgets/sidebar_filter.dart +++ b/lib/screens/common_widgets/sidebar_filter.dart @@ -19,7 +19,7 @@ class SidebarFilter extends StatelessWidget { decoration: BoxDecoration( borderRadius: kBorderRadius8, border: Border.all( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), ), child: Row( diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 9dd8fb7b..3be66748 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -88,7 +88,7 @@ class Dashboard extends ConsumerWidget { VerticalDivider( thickness: 1, width: 1, - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), Expanded( child: IndexedStack( diff --git a/lib/screens/envvar/editor_pane/secrets_pane.dart b/lib/screens/envvar/editor_pane/secrets_pane.dart index dcbec52e..e159dfd6 100644 --- a/lib/screens/envvar/editor_pane/secrets_pane.dart +++ b/lib/screens/envvar/editor_pane/secrets_pane.dart @@ -177,7 +177,7 @@ class EditEnvironmentSecretsState children: [ Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: kBorderRadius12, ), margin: kP10, diff --git a/lib/screens/envvar/editor_pane/variables_pane.dart b/lib/screens/envvar/editor_pane/variables_pane.dart index 639fe9f5..1d6eedb7 100644 --- a/lib/screens/envvar/editor_pane/variables_pane.dart +++ b/lib/screens/envvar/editor_pane/variables_pane.dart @@ -178,7 +178,7 @@ class EditEnvironmentVariablesState children: [ Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: kBorderRadius12, ), margin: kP10, diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index aa29d88b..39011d81 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -17,59 +17,54 @@ class EditRequestBody extends ConsumerWidget { final contentType = ref.watch(selectedRequestModelProvider .select((value) => value?.httpRequestModel?.bodyContentType)); - return Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, - ), - child: Column( - children: [ - const SizedBox( - height: kHeaderHeight, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Select Content Type:", - ), - DropdownButtonBodyContentType(), - ], - ), + return Column( + children: [ + const SizedBox( + height: kHeaderHeight, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Select Content Type:", + ), + DropdownButtonBodyContentType(), + ], ), - Expanded( - child: switch (contentType) { - ContentType.formdata => - const Padding(padding: kPh4, child: FormDataWidget()), - // TODO: Fix JsonTextFieldEditor & plug it here - ContentType.json => Padding( - padding: kPt5o10, - child: TextFieldEditor( - key: Key("$selectedId-json-body"), - fieldKey: "$selectedId-json-body-editor", - initialValue: requestModel?.httpRequestModel?.body, - onChanged: (String value) { - ref - .read(collectionStateNotifierProvider.notifier) - .update(selectedId, body: value); - }, - ), + ), + Expanded( + child: switch (contentType) { + ContentType.formdata => + const Padding(padding: kPh4, child: FormDataWidget()), + // TODO: Fix JsonTextFieldEditor & plug it here + ContentType.json => Padding( + padding: kPt5o10, + child: TextFieldEditor( + key: Key("$selectedId-json-body"), + fieldKey: "$selectedId-json-body-editor", + initialValue: requestModel?.httpRequestModel?.body, + onChanged: (String value) { + ref + .read(collectionStateNotifierProvider.notifier) + .update(selectedId, body: value); + }, ), - _ => Padding( - padding: kPt5o10, - child: TextFieldEditor( - key: Key("$selectedId-body"), - fieldKey: "$selectedId-body-editor", - initialValue: requestModel?.httpRequestModel?.body, - onChanged: (String value) { - ref - .read(collectionStateNotifierProvider.notifier) - .update(selectedId, body: value); - }, - ), + ), + _ => Padding( + padding: kPt5o10, + child: TextFieldEditor( + key: Key("$selectedId-body"), + fieldKey: "$selectedId-body-editor", + initialValue: requestModel?.httpRequestModel?.body, + onChanged: (String value) { + ref + .read(collectionStateNotifierProvider.notifier) + .update(selectedId, body: value); + }, ), - }, - ) - ], - ), + ), + }, + ) + ], ); } } diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart index 0bbe0688..5228c660 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart @@ -201,10 +201,6 @@ class _FormDataBodyState extends ConsumerState { return Stack( children: [ Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, - borderRadius: kBorderRadius12, - ), margin: kP10, child: Column( children: [ diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart index cce80d1c..ae083217 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart @@ -179,10 +179,6 @@ class EditRequestHeadersState extends ConsumerState { return Stack( children: [ Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, - borderRadius: kBorderRadius12, - ), margin: kP10, child: Column( children: [ diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart index e3f42a5c..861b95d5 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart @@ -179,10 +179,6 @@ class EditRequestURLParamsState extends ConsumerState { return Stack( children: [ Container( - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, - borderRadius: kBorderRadius12, - ), margin: kP10, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/lib/screens/home_page/editor_pane/url_card.dart b/lib/screens/home_page/editor_pane/url_card.dart index 0cfc070e..8640510c 100644 --- a/lib/screens/home_page/editor_pane/url_card.dart +++ b/lib/screens/home_page/editor_pane/url_card.dart @@ -12,10 +12,12 @@ class EditorPaneRequestURLCard extends StatelessWidget { @override Widget build(BuildContext context) { return Card( + color: kColorTransparent, + surfaceTintColor: kColorTransparent, elevation: 0, shape: RoundedRectangleBorder( side: BorderSide( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), borderRadius: kBorderRadius12, ), @@ -32,7 +34,6 @@ class EditorPaneRequestURLCard extends StatelessWidget { Expanded( child: URLTextField(), ), - SizedBox.shrink(), ], ) : const Row( diff --git a/lib/screens/mobile/widgets/page_base.dart b/lib/screens/mobile/widgets/page_base.dart index d1ee4e41..310e5cc6 100644 --- a/lib/screens/mobile/widgets/page_base.dart +++ b/lib/screens/mobile/widgets/page_base.dart @@ -21,9 +21,9 @@ class PageBase extends ConsumerWidget { final isDarkMode = ref.watch(settingsProvider.select((value) => value.isDark)); final scaffold = Scaffold( - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, primary: true, title: Text(title), centerTitle: true, diff --git a/lib/widgets/card_request_details.dart b/lib/widgets/card_request_details.dart index b12bc82e..282aec0e 100644 --- a/lib/widgets/card_request_details.dart +++ b/lib/widgets/card_request_details.dart @@ -9,9 +9,11 @@ class RequestDetailsCard extends StatelessWidget { @override Widget build(BuildContext context) { return Card( + color: kColorTransparent, + surfaceTintColor: kColorTransparent, shape: RoundedRectangleBorder( side: BorderSide( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), borderRadius: kBorderRadius12, ), diff --git a/lib/widgets/card_sidebar_environment.dart b/lib/widgets/card_sidebar_environment.dart index dadd3090..c07286b9 100644 --- a/lib/widgets/card_sidebar_environment.dart +++ b/lib/widgets/card_sidebar_environment.dart @@ -42,7 +42,8 @@ class SidebarEnvironmentCard extends StatelessWidget { final colorScheme = Theme.of(context).colorScheme; final Color color = isGlobal ? colorScheme.secondaryContainer : colorScheme.surface; - final Color colorVariant = colorScheme.surfaceVariant.withOpacity(0.5); + final Color colorVariant = + colorScheme.surfaceContainerHighest.withOpacity(0.5); final Color surfaceTint = colorScheme.primary; bool isSelected = selectedId == id; bool inEditMode = editRequestId == id; diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index 63cd1f7b..c6dd4cf6 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -42,7 +42,7 @@ class SidebarRequestCard extends StatelessWidget { Widget build(BuildContext context) { final Color color = Theme.of(context).colorScheme.surface; final Color colorVariant = - Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5); + Theme.of(context).colorScheme.surfaceContainerHighest.withOpacity(0.5); final Color surfaceTint = Theme.of(context).colorScheme.primary; bool isSelected = selectedId == id; bool inEditMode = editRequestId == id; diff --git a/lib/widgets/checkbox.dart b/lib/widgets/checkbox.dart index 53adf496..333efe08 100644 --- a/lib/widgets/checkbox.dart +++ b/lib/widgets/checkbox.dart @@ -22,16 +22,16 @@ class CheckBox extends StatelessWidget { borderRadius: BorderRadius.circular(3), ), side: BorderSide( - color: colorScheme.surfaceVariant, + color: colorScheme.surfaceContainerHighest, width: 1.5, ), splashRadius: 0, value: value, onChanged: onChanged, checkColor: colorScheme.onPrimary, - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.selected)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.selected)) { return colorScheme.primary; } return null; diff --git a/lib/widgets/codegen_previewer.dart b/lib/widgets/codegen_previewer.dart index 298610c7..2ee02755 100644 --- a/lib/widgets/codegen_previewer.dart +++ b/lib/widgets/codegen_previewer.dart @@ -121,7 +121,8 @@ class ViewCodePane extends StatelessWidget { : Theme.of(context).colorScheme.primaryContainer) .withOpacity(kForegroundOpacity), Theme.of(context).colorScheme.surface), - border: Border.all(color: Theme.of(context).colorScheme.surfaceVariant), + border: Border.all( + color: Theme.of(context).colorScheme.surfaceContainerHighest), borderRadius: kBorderRadius8, ); diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index a707eaad..736ffd83 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -93,7 +93,7 @@ class _TextFieldEditorState extends State { enabledBorder: OutlineInputBorder( borderRadius: kBorderRadius8, borderSide: BorderSide( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), ), filled: true, diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 7779f297..949af6fc 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -110,7 +110,7 @@ class _JsonTextFieldEditorState extends State { enabledBorder: OutlineInputBorder( borderRadius: kBorderRadius8, borderSide: BorderSide( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), ), filled: true, diff --git a/lib/widgets/field_cell.dart b/lib/widgets/field_cell.dart index 86e10ad6..f750368f 100644 --- a/lib/widgets/field_cell.dart +++ b/lib/widgets/field_cell.dart @@ -43,7 +43,7 @@ class CellField extends StatelessWidget { ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( - color: clrScheme.surfaceVariant, + color: clrScheme.surfaceContainerHighest, ), ), ), diff --git a/lib/widgets/field_cell_obscurable.dart b/lib/widgets/field_cell_obscurable.dart index 4526e7e2..61aa4bbe 100644 --- a/lib/widgets/field_cell_obscurable.dart +++ b/lib/widgets/field_cell_obscurable.dart @@ -57,7 +57,7 @@ class ObscurableCellField extends HookWidget { ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( - color: clrScheme.surfaceVariant, + color: clrScheme.surfaceContainerHighest, ), ), ), diff --git a/lib/widgets/field_header.dart b/lib/widgets/field_header.dart index 9e237c2c..2f1236fe 100644 --- a/lib/widgets/field_header.dart +++ b/lib/widgets/field_header.dart @@ -93,7 +93,7 @@ class _HeaderFieldState extends State { ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( - color: colorScheme.surfaceVariant, + color: colorScheme.surfaceContainerHighest, ), ), ), diff --git a/lib/widgets/field_raw.dart b/lib/widgets/field_raw.dart index cf7ef81e..8adf6fd0 100644 --- a/lib/widgets/field_raw.dart +++ b/lib/widgets/field_raw.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:apidash/consts.dart'; class RawTextField extends StatelessWidget { const RawTextField({ @@ -24,6 +25,7 @@ class RawTextField extends StatelessWidget { isDense: true, border: InputBorder.none, hintText: hintText, + contentPadding: kPv8, ), onTapOutside: (PointerDownEvent event) { FocusManager.instance.primaryFocus?.unfocus(); diff --git a/lib/widgets/json_previewer.dart b/lib/widgets/json_previewer.dart index b52dc86d..088c6026 100644 --- a/lib/widgets/json_previewer.dart +++ b/lib/widgets/json_previewer.dart @@ -246,9 +246,11 @@ class _JsonPreviewerState extends State { ), Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, border: Border.all( - color: Theme.of(context).colorScheme.surfaceVariant), + color: Theme.of(context) + .colorScheme + .surfaceContainerHighest), borderRadius: kBorderRadius8, ), child: Row( diff --git a/lib/widgets/response_widgets.dart b/lib/widgets/response_widgets.dart index 134aedc2..0d3bd7a7 100644 --- a/lib/widgets/response_widgets.dart +++ b/lib/widgets/response_widgets.dart @@ -405,7 +405,8 @@ class _BodySuccessState extends State { : Theme.of(context).colorScheme.primaryContainer) .withOpacity(kForegroundOpacity), Theme.of(context).colorScheme.surface), - border: Border.all(color: Theme.of(context).colorScheme.surfaceVariant), + border: Border.all( + color: Theme.of(context).colorScheme.surfaceContainerHighest), borderRadius: kBorderRadius8, ); @@ -425,7 +426,7 @@ class _BodySuccessState extends State { ? const SizedBox() : SegmentedButton( style: const ButtonStyle( - padding: MaterialStatePropertyAll( + padding: WidgetStatePropertyAll( EdgeInsets.symmetric( horizontal: 8, ), diff --git a/lib/widgets/splitview_dashboard.dart b/lib/widgets/splitview_dashboard.dart index 339f3aee..ca89e729 100644 --- a/lib/widgets/splitview_dashboard.dart +++ b/lib/widgets/splitview_dashboard.dart @@ -35,7 +35,7 @@ class DashboardSplitViewState extends State { data: MultiSplitViewThemeData( dividerThickness: 3, dividerPainter: DividerPainters.background( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, highlightedColor: Theme.of(context).colorScheme.outline.withOpacity( kHintOpacity, ), diff --git a/lib/widgets/splitview_drawer.dart b/lib/widgets/splitview_drawer.dart index 80669d89..576e525d 100644 --- a/lib/widgets/splitview_drawer.dart +++ b/lib/widgets/splitview_drawer.dart @@ -60,7 +60,7 @@ class DrawerSplitView extends StatelessWidget { child: IconButton( icon: Icon( rightDrawerIcon ?? Icons.arrow_forward, - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, ), onPressed: () { scaffoldKey.currentState!.openEndDrawer(); diff --git a/lib/widgets/splitview_equal.dart b/lib/widgets/splitview_equal.dart index 28f85a76..413d42fa 100644 --- a/lib/widgets/splitview_equal.dart +++ b/lib/widgets/splitview_equal.dart @@ -30,7 +30,7 @@ class _EqualSplitViewState extends State { data: MultiSplitViewThemeData( dividerThickness: 3, dividerPainter: DividerPainters.background( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, highlightedColor: Theme.of(context).colorScheme.outline.withOpacity( kHintOpacity, ), diff --git a/lib/widgets/tables.dart b/lib/widgets/tables.dart index c238dae0..6a4a9304 100644 --- a/lib/widgets/tables.dart +++ b/lib/widgets/tables.dart @@ -18,7 +18,7 @@ class MapTable extends StatelessWidget { return Table( border: TableBorder( horizontalInside: BorderSide( - color: Theme.of(context).colorScheme.surfaceVariant, + color: Theme.of(context).colorScheme.surfaceContainerHighest, ), ), columnWidths: const {