Skip to content

Commit

Permalink
add video search and page change clear search history
Browse files Browse the repository at this point in the history
  • Loading branch information
longforus committed Sep 6, 2019
1 parent 3eaa07e commit d0422e6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
42 changes: 31 additions & 11 deletions flutter_module/lib/com/longforus/fPix/page/ImagePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,61 @@ import 'package:fPix/com/longforus/fPix/widget/ImageTopBar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class ImagePage extends StatefulWidget {
const ImagePage({
Key key,
}) : super(key: key);
class ImageAndVideoPage extends StatefulWidget {
const ImageAndVideoPage({Key key, this.isVideo = false}) : super(key: key);
final bool isVideo;

@override
State<StatefulWidget> createState() {
return new _ImagePageState();
return new _ImageAndVideoPageState(isVideo);
}
}

class _ImagePageState extends State<ImagePage> with TickerProviderStateMixin {
class _ImageAndVideoPageState extends State<ImageAndVideoPage> with SingleTickerProviderStateMixin {
String searchContent;

final bool isVideo;
TabController _tabController;
TabBarView tabBarView;
ImageTopBar imageTopBar;



void _onTabChange() {
debugPrint("onchangge $searchContent");
if (searchContent != null) {
ImageGridView currentImageGridView = tabBarView.children[_tabController.index];
currentImageGridView.clearSearchStatus();
setState(() {
searchContent = null;
});
}
}

@override
void initState() {
_tabController = TabController(length: typeList.length, vsync: this);
_tabController.addListener(_onTabChange);
tabBarView = TabBarView(
// These are the contents of the tab views, below the tabs.
children: typeList.map((String type) {
return new ImageGridView(imageType: type);
return new ImageGridView(
imageType: type,
isVideo: isVideo,
);
}).toList(),
controller: _tabController,
);
imageTopBar = new ImageTopBar(
isVideo: false,
isVideo: isVideo,
tabController: _tabController,
);
super.initState();
}

@override
void dispose() {
_tabController.removeListener(_onTabChange);
super.dispose();
}

@override
Widget build(BuildContext context) {
return new Scaffold(
Expand Down Expand Up @@ -101,4 +119,6 @@ class _ImagePageState extends State<ImagePage> with TickerProviderStateMixin {
),
);
}

_ImageAndVideoPageState(this.isVideo);
}
3 changes: 3 additions & 0 deletions flutter_module/lib/com/longforus/fPix/page/VideoPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:fPix/com/longforus/fPix/view/GridImageView.dart';
import 'package:fPix/com/longforus/fPix/widget/ImageTopBar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
///
///and image using one page
@deprecated
class VideoPage extends StatefulWidget {
const VideoPage({
Key key,
Expand Down
5 changes: 3 additions & 2 deletions flutter_module/lib/com/longforus/fPix/widget/ImageTopBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:fPix/com/longforus/fPix/widget/cached_network_image.dart';
import 'package:flutter/material.dart';

class ImageTopBar extends StatefulWidget {
ImageTopBar({Key key, this.isVideo}) : super(key: key);
ImageTopBar({Key key, this.isVideo,this.tabController}) : super(key: key);
final bool isVideo;

final TabController tabController;
@override
State<StatefulWidget> createState() {
return new ImageTopBarState();
Expand Down Expand Up @@ -100,6 +100,7 @@ class ImageTopBarState extends State<ImageTopBar> {
)
],
bottom: TabBar(
controller: widget.tabController,
isScrollable: true,
tabs: typeList.map((String str) {
return new Tab(
Expand Down
5 changes: 2 additions & 3 deletions flutter_module/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:async';
import 'package:fPix/com/longforus/fPix/page/FavoritePage.dart';
import 'package:fPix/com/longforus/fPix/page/ImagePage.dart';
import 'package:fPix/com/longforus/fPix/page/SettingsPage.dart';
import 'package:fPix/com/longforus/fPix/page/VideoPage.dart';
import 'package:fPix/com/longforus/fPix/widget/flutter_cache_manager.dart';
import 'package:fPix/com/longforus/fPix/SentryConfig.dart' as sentryConfig;
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -86,9 +85,9 @@ class _MyHomePageState extends State<MyHomePage> {
Widget _getPage(int selectedPageIndex) {
switch (selectedPageIndex) {
case 0:
return new ImagePage();
return new ImageAndVideoPage(key: Key("image") ,);
case 1:
return new VideoPage();
return new ImageAndVideoPage(key: Key("video"),isVideo: true,);
case 2:
return new FavoritePage();
case 3:
Expand Down

0 comments on commit d0422e6

Please sign in to comment.