Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
Search + Channel Videos (#2)
Browse files Browse the repository at this point in the history
* Adds a bottom bar with an additional top videos tab

* Add search

* Circular ripple effect around search icon

* Improve display of Video lists

* Remove demo vids

* Revert the changes to gradle

* Update pubspec.yaml
  • Loading branch information
brianegan authored and matanlurey committed Jun 25, 2017
1 parent 54547ce commit e179567
Show file tree
Hide file tree
Showing 17 changed files with 693 additions and 148 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ flutter {
}

dependencies {
compile 'com.android.support:appcompat-v7:+'
androidTestCompile 'com.android.support:support-annotations:25.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
Expand Down
5 changes: 4 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application android:name="io.flutter.app.FlutterApplication" android:label="flitch" android:icon="@mipmap/ic_launcher">
<application android:name="io.flutter.app.FlutterApplication" android:label="Flitch" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar"
Expand All @@ -28,5 +28,8 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity android:name="com.flutter_webview_plugin.WebviewActivity"
android:parentActivityName=".MainActivity" android:theme="@style/FlitchTheme" />
</application>
</manifest>
8 changes: 8 additions & 0 deletions android/app/src/main/res/values-v21/flitch_theme.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FlitchTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:colorPrimary">#673AB7</item>
<item name="android:colorPrimaryDark">#4d2b89</item>
<item name="android:colorAccent">#9E9E9E</item>
</style>
</resources>
12 changes: 12 additions & 0 deletions android/app/src/main/res/values/flitch_theme.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FlitchTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:actionBarStyle">@style/FlitchActionBarTheme</item>
</style>

<style name="FlitchActionBarTheme" parent="@android:style/Widget.DeviceDefault.ActionBar">
<item name="android:background">#673AB7</item>
<item name="android:backgroundStacked">?attr/colorPrimary</item>
<item name="android:backgroundSplit">?attr/colorPrimary</item>
</style>
</resources>
8 changes: 3 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flitch/src/services.dart';
import 'package:flutter/widgets.dart';
import 'package:twitch/twitch.dart';

import 'package:twitch/twitch.dart';
import 'src/application.dart';
import 'src/services.dart';

// Please register a different client ID before publishing:
// https://www.twitch.tv/settings/connections
Expand All @@ -15,8 +15,6 @@ import 'src/services.dart';
const _twitchClientId = '6gtkhkgt33mb3hujfq5f4vc0mrn4kc';

void main() {
setUpServices(
twitch: new Twitch(new TwitchHttp(clientId: _twitchClientId)),
);
Services.setup(new Twitch(new TwitchHttp(clientId: _twitchClientId)));
runApp(new FlitchApp());
}
4 changes: 2 additions & 2 deletions lib/src/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import 'package:flutter/material.dart';

import 'views/home.dart';
import 'package:flitch/src/screens/home.dart';

class FlitchApp extends MaterialApp {
FlitchApp()
: super(
debugShowCheckedModeBanner: false,
title: 'Flitch',
home: const HomeWidget(),
home: const HomeScreen(),
theme: _twitchTheme,
);
}
Expand Down
22 changes: 22 additions & 0 deletions lib/src/screens/channel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2017, Google Inc. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flitch/src/services.dart';
import 'package:flitch/src/widgets/videos.dart';
import 'package:flutter/material.dart';
import 'package:twitch/twitch.dart';

class ChannelScreen extends StatelessWidget {
final Channel channel;

const ChannelScreen(this.channel);

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Videos from ${channel.name}")),
body: new VideosList(Services.twitch.getChannelVideos(channel.id)));
}
}
47 changes: 30 additions & 17 deletions lib/src/views/home.dart → lib/src/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flitch/src/widgets/top_videos.dart';
import 'package:flitch/src/screens/search.dart';
import 'package:flitch/src/services.dart';
import 'package:flitch/src/widgets/videos.dart';
import 'package:flutter/material.dart';
import '../services.dart' as services;
import '../widgets/game.dart';
import '../widgets/top_games.dart';

class HomeWidget extends StatefulWidget {
const HomeWidget();
class HomeScreen extends StatefulWidget {
const HomeScreen();

@override
State<StatefulWidget> createState() {
return new HomeWidgetState();
}
}

class HomeWidgetState extends State<HomeWidget> {
class HomeWidgetState extends State<HomeScreen> {
int _currentIndex = 0;
final List<Screen> _screens = [
new Screen(
final List<Tab> _tabs = [
new Tab(
title: 'Top Games',
body: new TopGameList(),
key: new Key('TopGamesList'),
icon: Icons.games,
),
new Screen(
new Tab(
title: 'Top Videos',
body: new TopVideosList(services.twitch),
body: new VideosList(Services.twitch.getTopVideos()),
key: new Key('TopVideosList'),
icon: Icons.videocam,
),
Expand All @@ -40,11 +41,23 @@ class HomeWidgetState extends State<HomeWidget> {
return new Scaffold(
appBar: new AppBar(
title: new Text('Flitch'),
actions: [
new IconButton(
icon: new Icon(Icons.search),
padding: new EdgeInsets.fromLTRB(16.0, 0.0, 12.0, 0.0),
onPressed: () async {
await Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new SearchScreen()));
},
tooltip: 'Search'),
],
),
body: new Stack(
children: (_screens
children: (_tabs
// Get all inactive screens
.where((screen) => _screens.indexOf(screen) != _currentIndex)
.where((screen) => _tabs.indexOf(screen) != _currentIndex)
// Place them on the bottom of the Stack, and fade em out
.map((screen) => new AnimatedOpacity(
opacity: 0.0,
Expand All @@ -56,27 +69,27 @@ class HomeWidgetState extends State<HomeWidget> {
..add(new AnimatedOpacity(
opacity: 1.0,
duration: transitionDuration,
child: _screens[_currentIndex].body,
key: _screens[_currentIndex].key)))),
child: _tabs[_currentIndex].body,
key: _tabs[_currentIndex].key)))),
bottomNavigationBar: new BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (currentIndex) {
setState(() {
_currentIndex = currentIndex;
});
},
items: _screens
items: _tabs
.map((item) => new BottomNavigationBarItem(
icon: new Icon(item.icon), title: new Text(item.title)))
.toList()));
}
}

class Screen {
class Tab {
final Widget body;
final IconData icon;
final String title;
final Key key;

Screen({this.body, this.icon, this.title, this.key});
Tab({this.body, this.icon, this.title, this.key});
}
55 changes: 55 additions & 0 deletions lib/src/screens/search.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2017, Google Inc. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flitch/src/widgets/search_channels.dart';
import 'package:flutter/material.dart';

class SearchScreen extends StatefulWidget {
const SearchScreen();

@override
State<StatefulWidget> createState() {
return new SearchScreenState();
}
}

class SearchScreenState extends State<SearchScreen> {
String _query = "";

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Container(
padding: new EdgeInsets.only(right: 12.0),
child: new TextField(
onSubmitted: (query) {
setState(() {
_query = query;
});
},
autofocus: true,
decoration: new InputDecoration(
hideDivider: true,
hintText: "Search channels...",
hintStyle: new TextStyle(
color: new Color.fromARGB(120, 255, 255, 255),
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
),
style: new TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.normal)),
),
),
body: _query.isEmpty
? new Container()
: new SearchChannelsList(
_query,
key: new Key(_query),
));
}
}
18 changes: 9 additions & 9 deletions lib/src/services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import 'package:twitch/twitch.dart';

Twitch _twitch;
class Services {
static final Services _singleton = new Services._internal();
static final Twitch twitch = _singleton._twitch;
Twitch _twitch;

/// Sets up services for the entire application.
void setUpServices({
Twitch twitch,
}) {
_twitch = twitch;
}
Services._internal();

/// Returns the Twitch service.
Twitch get twitch => _twitch;
static void setup(Twitch twitch) {
_singleton._twitch = twitch;
}
}
Loading

0 comments on commit e179567

Please sign in to comment.