Skip to content
Binary file modified dist/images/app-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions lib/views/app_view.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:outlet/core/application.dart';
import 'package:outlet/views/components/app_actions.dart';
import 'package:outlet/views/components/app_description.dart';
import 'package:outlet/views/components/app_info.dart';
import 'package:outlet/views/components/app_links.dart';
import 'package:outlet/views/components/app_update.dart';
import 'package:outlet/views/components/screenshots.dart';

class AppView extends StatelessWidget {
Expand Down Expand Up @@ -42,8 +42,8 @@ class AppView extends StatelessWidget {
Expanded(
flex: 1,
child: Column(spacing: 16.0, children: [
AppInfo(app: app!),
AppActions(id: app!.id),
AppInfo(id: app!.id),
if (!app!.current) AppUpdate(id: app!.id),
AppDescription(app: app!),
AppLinks(app: app!),
])),
Expand All @@ -58,8 +58,8 @@ class AppView extends StatelessWidget {
BoxConstraints(minHeight: viewportHeight),
padding: const EdgeInsets.fromLTRB(20, 15, 20, 20),
child: Column(spacing: 16.0, children: [
AppInfo(app: app!),
AppActions(id: app!.id),
AppInfo(id: app!.id),
if (!app!.current) AppUpdate(id: app!.id),
AppDescription(app: app!),
Screenshots(screenshots: app!.screenshots),
AppLinks(app: app!),
Expand Down
138 changes: 0 additions & 138 deletions lib/views/components/app_actions.dart

This file was deleted.

88 changes: 5 additions & 83 deletions lib/views/components/app_description.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter/material.dart';
import 'package:outlet/core/application.dart';
import 'package:outlet/views/components/expandable_container.dart';
import 'package:outlet/views/components/theme.dart';
import 'package:outlet/views/components/badges.dart';

Expand Down Expand Up @@ -32,12 +33,13 @@ class AppDescription extends StatelessWidget {
const SizedBox(height: 8),
Row(
children: [
const Expanded(
child: Text('Description',
style: TextStyle(
Expanded(
child: Text(app.getLocalizedSummary(),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
))),
const SizedBox(width: 10),
CategoryList(categories: app.categories, size: 30),
],
),
Expand Down Expand Up @@ -65,83 +67,3 @@ class AppDescription extends StatelessWidget {
);
}
}

class ExpandableContainer extends StatefulWidget {
final Widget child;
final double maxHeight;

const ExpandableContainer({
super.key,
required this.child,
this.maxHeight = 150.0,
});

@override
State<ExpandableContainer> createState() => _ExpandableContainerState();
}

class _ExpandableContainerState extends State<ExpandableContainer> {
bool _isExpanded = false;
bool _showExpandButton = false;

final GlobalKey _contentKey = GlobalKey();

@override
void initState() {
super.initState();
WidgetsBinding.instance
.addPostFrameCallback((_) => _measureContentHeight());
}

void _measureContentHeight() {
final RenderBox? renderBox =
_contentKey.currentContext?.findRenderObject() as RenderBox?;

if (renderBox != null && renderBox.hasSize) {
final double actualHeight = renderBox.size.height;

if (actualHeight - widget.maxHeight > 20 && !_showExpandButton) {
setState(() {
_showExpandButton = true;
});
}
}
}

@override
Widget build(BuildContext context) {
final double maxConstraint =
_isExpanded || !_showExpandButton ? double.infinity : widget.maxHeight;

return Column(
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: maxConstraint,
),
child: KeyedSubtree(
key: _contentKey,
child: widget.child,
),
),
if (_showExpandButton)
Container(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
setState(() {
_isExpanded = !_isExpanded;
});
},
style: const ButtonStyle(
backgroundColor: WidgetStatePropertyAll<Color>(Colors.black),
),
child: Text(
_isExpanded ? 'Show Less' : 'Show More',
style: const TextStyle(color: Colors.white),
),
)),
],
);
}
}
Loading