fluffychat/lib/widgets/layouts/side_view_layout.dart

44 lines
1.4 KiB
Dart
Raw Normal View History

2021-05-23 18:46:15 +02:00
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
2021-05-23 18:46:15 +02:00
import 'package:vrouter/vrouter.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/config/themes.dart';
2021-05-23 18:46:15 +02:00
class SideViewLayout extends StatelessWidget {
final Widget mainView;
2021-11-19 20:28:17 +01:00
final Widget? sideView;
2021-05-23 18:46:15 +02:00
2021-11-19 20:28:17 +01:00
const SideViewLayout({Key? key, required this.mainView, this.sideView})
2021-05-23 18:46:15 +02:00
: super(key: key);
@override
Widget build(BuildContext context) {
var currentUrl = Uri.decodeFull(VRouter.of(context).url);
if (!currentUrl.endsWith('/')) currentUrl += '/';
final hideSideView = currentUrl.split('/').length == 4;
2021-11-19 20:28:17 +01:00
final sideView = this.sideView;
2021-05-23 18:46:15 +02:00
return sideView == null
? mainView
2021-05-23 20:18:29 +02:00
: MediaQuery.of(context).size.width < FluffyThemes.columnWidth * 3.5 &&
2021-05-23 18:46:15 +02:00
!hideSideView
? sideView
: Row(
children: [
Expanded(
child: ClipRRect(child: mainView),
),
Container(
width: 1.0,
color: Theme.of(context).dividerColor,
),
AnimatedContainer(
2021-10-14 18:09:30 +02:00
duration: const Duration(milliseconds: 300),
2021-05-23 18:46:15 +02:00
clipBehavior: Clip.antiAlias,
2021-10-14 18:09:30 +02:00
decoration: const BoxDecoration(),
2021-05-23 18:46:15 +02:00
width: hideSideView ? 0 : 360.0,
child: hideSideView ? null : sideView,
),
],
);
}
}