Skip to content

Commit

Permalink
Added Star wars webview page
Browse files Browse the repository at this point in the history
  • Loading branch information
luuolli committed Sep 12, 2021
1 parent 8746b25 commit d11c042
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/src/app/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_modular/flutter_modular.dart';
import 'package:starwars/src/core/core.dart';
import 'package:starwars/src/features/favorites/controllers/favorite_controller.dart';
import 'package:starwars/src/features/favorites/services/favorite_database.dart';
import 'package:starwars/src/features/starwars_webview/views/starwars_web_page.dart';

import '../features/home/home_page.dart';

Expand All @@ -23,6 +24,12 @@ class AppModule extends Module {
ChildRoute(
'/',
child: (_, __) => HomePage(favoriteStore: Modular.get()),
children: [
ChildRoute(
'starwars-web',
child: (_, __) => const StarwarsWebPage(),
),
],
),
];
}
11 changes: 9 additions & 2 deletions lib/src/features/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';

import '../../core/core.dart';
import '../favorites/controllers/favorite_controller.dart';
Expand Down Expand Up @@ -71,8 +72,14 @@ class _HomePageState extends State<HomePage> {
),
),
expandedHeight: 180,
title: const CupertinoButton(
child: Icon(Icons.public), onPressed: null),
title: CupertinoButton(
padding: EdgeInsets.zero,
child: const Icon(Icons.public),
onPressed: () {
print(Modular.to.path);
Modular.to.pushNamed('starwars-web', forRoot: true);
},
),
actions: const [
CupertinoButton(child: Icon(Icons.person), onPressed: null),
],
Expand Down
24 changes: 24 additions & 0 deletions lib/src/features/starwars_webview/views/starwars_web_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/cupertino.dart';
import 'package:starwars/src/core/core.dart';
import 'package:webview_flutter/webview_flutter.dart';

class StarwarsWebPage extends StatelessWidget {
const StarwarsWebPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
backgroundColor: StarwarsColors.backgroundDark,
middle: Text(
'Star Wars - web',
style: TextStyle(color: StarwarsColors.white),
),
),
child: const WebView(
initialUrl: 'https://www.starwars.com/community',
javascriptMode: JavascriptMode.unrestricted,
),
);
}
}

0 comments on commit d11c042

Please sign in to comment.