-
-
Notifications
You must be signed in to change notification settings - Fork 855
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix dio error on web; added page splitting animations
- Loading branch information
Showing
20 changed files
with
162 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'unsupported.dart' | ||
if (dart.library.html) 'web_adapter.dart' | ||
if (dart.library.io) 'mobile_adapter.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:dio/io.dart'; | ||
|
||
HttpClientAdapter getAdapter() { | ||
return IOHttpClientAdapter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:dio/dio.dart'; | ||
|
||
HttpClientAdapter getAdapter() { | ||
throw 'unsupported platform'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:dio/browser.dart'; | ||
import 'package:dio/dio.dart'; | ||
|
||
HttpClientAdapter getAdapter() { | ||
return BrowserHttpClientAdapter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
lib/src/common/presentation/ui/widgets/animated_page_splitter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class AnimatedPageSplitter extends StatelessWidget { | ||
final Widget leftChild; | ||
final Widget? rightChild; | ||
final bool isExpanded; | ||
final Duration animationDuration; | ||
final double dividerWidth; | ||
|
||
const AnimatedPageSplitter({ | ||
super.key, | ||
required this.leftChild, | ||
this.rightChild, | ||
this.isExpanded = false, | ||
this.animationDuration = const Duration(milliseconds: 250), | ||
this.dividerWidth = 16.0, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return LayoutBuilder( | ||
builder: (context, constraints) { | ||
final screenWidth = constraints.maxWidth; | ||
final firstHalfWidth = (screenWidth - dividerWidth) / 2.7; | ||
final secondHalfWidth = screenWidth - firstHalfWidth; | ||
|
||
final leftSectionWidth = isExpanded ? firstHalfWidth : screenWidth; | ||
final rightSectionWidth = isExpanded ? secondHalfWidth : 0.0; | ||
final animatedDividerWidth = isExpanded ? dividerWidth : 0.0; | ||
|
||
return Row( | ||
children: [ | ||
AnimatedContainer( | ||
duration: animationDuration, | ||
width: leftSectionWidth, | ||
child: leftChild, | ||
), | ||
AnimatedContainer( | ||
duration: animationDuration, | ||
width: animatedDividerWidth, | ||
color: Colors.transparent, | ||
child: animatedDividerWidth > 0 ? const VerticalDivider() : null, | ||
), | ||
Expanded( | ||
child: AnimatedContainer( | ||
duration: animationDuration, | ||
width: rightSectionWidth, | ||
child: rightChild, | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 8 additions & 16 deletions
24
lib/src/features/explore/presentation/ui/screens/explore_screen_large.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
import 'package:auto_route/auto_route.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_ebook_app/src/common/common.dart'; | ||
import 'package:flutter_ebook_app/src/features/features.dart'; | ||
|
||
class ExploreScreenLarge extends StatefulWidget { | ||
class ExploreScreenLarge extends StatelessWidget { | ||
const ExploreScreenLarge({super.key}); | ||
|
||
@override | ||
State<ExploreScreenLarge> createState() => _ExploreScreenLargeState(); | ||
} | ||
|
||
class _ExploreScreenLargeState extends State<ExploreScreenLarge> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
WidgetsBinding.instance.addPostFrameCallback((_) { | ||
context.router.replace(const ExploreRouteSmall()); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AutoRouter( | ||
placeholder: (context) => const SizedBox.shrink(), | ||
final isNestedEmpty = context.watchRouter.topRoute.name == 'ExploreRoute'; | ||
|
||
return AnimatedPageSplitter( | ||
isExpanded: !isNestedEmpty, | ||
leftChild: const ExploreScreenSmall(), | ||
rightChild: const AutoRouter(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
lib/src/features/settings/presentation/ui/screens/settings_screen_large.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import 'package:auto_route/auto_route.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:flutter_ebook_app/src/features/settings/settings.dart'; | ||
import 'package:flutter_ebook_app/src/common/common.dart'; | ||
import 'package:flutter_ebook_app/src/features/features.dart'; | ||
|
||
class SettingsScreenLarge extends StatelessWidget { | ||
const SettingsScreenLarge({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Row( | ||
children: [ | ||
SizedBox(width: 400, child: SettingsScreenSmall()), | ||
VerticalDivider(thickness: 1, width: 2), | ||
Expanded(child: AutoRouter()), | ||
], | ||
final isNestedEmpty = context.watchRouter.topRoute.name == 'SettingsRoute'; | ||
|
||
return AnimatedPageSplitter( | ||
isExpanded: !isNestedEmpty, | ||
leftChild: const SettingsScreenSmall(), | ||
rightChild: const AutoRouter(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 29 additions & 2 deletions
31
lib/src/features/tabs/presentation/ui/screens/tabs_screen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters