-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from AlexBacich/feature/null-safety
- Updated library to null-safety Awesome work!!!
- Loading branch information
Showing
36 changed files
with
923 additions
and
796 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:rx_widget_demo/homepage/weather_list_view.dart'; | ||
import 'package:rx_widget_demo/keys.dart'; | ||
import 'package:rx_widget_demo/model_provider.dart'; | ||
import 'package:rx_widget_demo/service/weather_entry.dart'; | ||
import 'package:rx_widgets/rx_widgets.dart'; | ||
|
||
// ignore_for_file: deprecated_member_use | ||
|
||
const noResultsText = 'No matching city data found. Try refining search.'; | ||
|
||
class HomePage extends StatelessWidget { | ||
final TextEditingController _controller = TextEditingController(); | ||
|
||
HomePage({ | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final homePageModel = ModelProvider.of(context); | ||
/*return Scaffold( | ||
appBar: AppBar(title: AppBar(title: Text('WeatherDemo'))), | ||
resizeToAvoidBottomInset: false, | ||
body: SafeArea( | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: TextField( | ||
key: AppKeys.textField, | ||
autocorrect: false, | ||
controller: _controller, | ||
decoration: InputDecoration( | ||
hintText: "Filter cities", | ||
), | ||
style: TextStyle( | ||
fontSize: 20.0, | ||
), | ||
onChanged: (s) => homePageModel.textChangedCommand(s), | ||
// onChanged: ModelProvider.of(context).textChangedCommand, | ||
), | ||
), | ||
Text('My Message'), | ||
], | ||
), | ||
), | ||
);*/ | ||
return Scaffold( | ||
appBar: AppBar(title: Text("WeatherDemo")), | ||
resizeToAvoidBottomInset: false, | ||
body: SafeArea( | ||
child: Column( | ||
children: <Widget>[ | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: TextField( | ||
key: AppKeys.textField, | ||
autocorrect: false, | ||
controller: _controller, | ||
decoration: InputDecoration(hintText: "Filter cities"), | ||
style: TextStyle( | ||
fontSize: 20.0, | ||
), | ||
onChanged: (s) => homePageModel.textChangedCommand(s), | ||
), | ||
), | ||
Expanded( | ||
child: RxLoader<List<WeatherEntry>>( | ||
spinnerKey: AppKeys.loadingSpinner, | ||
radius: 25.0, | ||
commandResults: homePageModel.updateWeatherCommand.results, | ||
dataBuilder: (_, data) { | ||
if (data.isEmpty) return Center(child: Text(noResultsText)); | ||
return WeatherListView(data, key: AppKeys.weatherList); | ||
}, | ||
placeHolderBuilder: (_) => Center( | ||
key: AppKeys.loaderPlaceHolder, child: Text("No Data")), | ||
errorBuilder: (_, ex) => Center( | ||
key: AppKeys.loaderError, | ||
child: Text("Error: ${ex.toString()}")), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Row( | ||
children: <Widget>[ | ||
Expanded( | ||
// This might be solved with a StreamBuilder to but it should show `WidgetSelector` | ||
child: WidgetSelector( | ||
key: AppKeys.widgetSelector, | ||
buildEvents: | ||
homePageModel.updateWeatherCommand.canExecute, | ||
//We access our ViewModel through the inherited Widget | ||
onTrue: RaisedButton( | ||
key: AppKeys.updateButtonEnabled, | ||
child: Text("Update"), | ||
onPressed: () { | ||
_controller.clear(); | ||
homePageModel.updateWeatherCommand(''); | ||
}, | ||
), | ||
onFalse: RaisedButton( | ||
key: AppKeys.updateButtonDisabled, | ||
child: Text("Please Wait"), | ||
onPressed: null, | ||
), | ||
), | ||
), | ||
StateFullSwitch( | ||
state: true, | ||
onChanged: (b) => homePageModel.switchChangedCommand(b), | ||
// onChanged: homePageModel.switchChangedCommand, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
/// As the normal switch does not even remember and display its current state | ||
/// we us this one | ||
class StateFullSwitch extends StatefulWidget { | ||
final bool state; | ||
final ValueChanged<bool> onChanged; | ||
|
||
StateFullSwitch({required this.state, required this.onChanged}); | ||
|
||
@override | ||
StateFullSwitchState createState() { | ||
return StateFullSwitchState(state, onChanged); | ||
} | ||
} | ||
|
||
class StateFullSwitchState extends State<StateFullSwitch> { | ||
bool state; | ||
ValueChanged<bool> handler; | ||
|
||
StateFullSwitchState(this.state, this.handler); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Switch( | ||
key: AppKeys.updateSwitch, | ||
value: state, | ||
onChanged: (b) { | ||
setState(() => state = b); | ||
handler(b); | ||
}, | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.