GithubHelp home page GithubHelp logo

cosmicmind / samples Goto Github PK

View Code? Open in Web Editor NEW
404.0 25.0 265.0 208.45 MB

Sample projects using Material, Graph, and Algorithm.

Home Page: http://cosmicmind.com

License: BSD 3-Clause "New" or "Revised" License

Swift 97.02% Ruby 2.94% Shell 0.04%
cosmicmind material graph algorithm us database data data-structure material-design projects

samples's Introduction

CosmicMind

Samples is a collection of example projects that use Material, Motion, Graph, and Algorithm.

Photos Sample

Using Material and Motion, a dynamic photo gallery is created with dynamic animations used during transitions.

Photos

Cards & Tabs

In this sample project, Material is used to create a tabbing layout with dynamically sized Cards within a TableView.

Cards & Tabs

Graph Search

Using the Graph Search API is incredibly flexible. In the following example, Search is used to create a live search on user names with a dynamic UI provided by Material's SearchBar.

Graph Search

Learn, Enjoy, Create

Many more sample projects are available within the Samples repository.

Requirements

  • iOS 8.0+ / Mac OS X 10.10+
  • Xcode 8.0+

Communication

  • If you need help, use Stack Overflow. (Tag 'cosmicmind')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, and can provide steps to reliably reproduce it, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Read Material - It's time to download to learn how to install Material & Motion using GitHub, CocoaPods, and Carthage.

To install all pods, use the following script:

$ ./install_all_pods.sh

License

Copyright (C) 2015 - 2018, Daniel Dahan and CosmicMind, Inc. http://cosmicmind.com. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of CosmicMind nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

samples's People

Contributors

cartickn avatar danieldahan avatar laiso avatar leilee avatar lunacodegirl avatar macmedan avatar orkhanalikhanov avatar yasirmturk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

samples's Issues

Best practice to use controls

All given controls are great individually but how to implement when all controls are come to gather?

Like in my app I have status bar + Tool bar + page tab bar. And each tab contain collection view. To achieve above I have done below code.
AppDelegate

var window: UIWindow?
    
    lazy var movieVillaViewController: MovieVillaViewController = {
        return UIStoryboard.viewController(identifier: "MovieVillaViewController") as! MovieVillaViewController
    }()
    
    lazy var upcomingViewController: UpcomingViewController = {
        return UIStoryboard.viewController(identifier: "UpcomingViewController") as! UpcomingViewController
    }()
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {                
        let viewControllers = [playingNowViewController, upcomingViewController] as [UIViewController]
        
        let pageTabBarController = MVPageTabBarController(viewControllers: viewControllers, selectedIndex: 0)
        let toolbarController = AppToolbarController(rootViewController: pageTabBarController)
               
        window = UIWindow(frame: UIScreen.main.bounds)
        window!.rootViewController = toolbarController
        window!.makeKeyAndVisible()
        
        return true
    }

So my view is looking somthing like below

simulator screen shot 25-nov-2016 3

Now when user click on blue search button. It should open new view with only search bar on top and containing collection view under it, and don't want toolbar, page tab bar control.

Issue is in given example on git hub for search bar is added in AppDelegate as rootViewController but I do have some other controls as rootViewController as you can see above.

So can you please suggest best way how to implement these great controls which can work with each other.

May be my question is silly to you but I am beginner in iOS.

Thanks

TextField build failed using Material 2.3.4

When I tried to build TextField Sample using Materail 2.3.4, it failed and Xcode 8 report that there had an error in Material+UIImage.swift at line 309. The information as follows:

"Material+UIImage.swift:309:30: Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions"

Help with MenuController

Hi Daniel,

Firstly, I love Material, I'm really enjoying using it in my project. I'm new to iOS and Swift, so Material is a great kickstart to getting me up and running.

I have a requirement where I want to use the MenuController in a single View Controller in the app, as the menu items are specific to that view controller. The example shows how it is used as a application wide MenuController.

Currently, similar to the example, I have a SearchMenuViewController which is equivalent to the example AppMenuViewController, and I have a SearchMenuItemsViewController which is the equivalent to the example RootViewController. In my parent view controller, I have a property for my SearchMenuViewController which I instantiate in the same way as the example -

searchMenuVC = SearchMenuViewController(rootViewController: SearchMenuItemsViewController())

When I debug the app, I see the trace drops into ViewDidLoad on the SearchMenuItemsViewController, but never drops into ViewDidAppear, so the prepareMenuController function never gets called, and thus doesn't add the menu item subviews and set the delegate. If I move the prepareMenuController call to happen in ViewDidLoad, I can see the menu item fab button in my parent VC, but it doesn't respond to taps.

Do you have an example that I can follow for using the MenuController in a single parent view controller, or can you give me any pointers where I might be going wrong?

Thanks
Alex

Issue building projects using CocoaPods.

I am trying to run the sample programs that are present in this repo but I am facing problems
According to the installation instructions mentioned in the link I have executed the shell script but I get the following errors on command line. The cococapods version is 1.1.0.beta.1
https://github.com/CosmicMind/Samples/wiki/Installation
I
screen shot 2016-11-15 at 4 09 05 pm

Then I tried to go the folder BottomNavigationController and then did "pod install" . It installed the dependencies but when I open xcworkspace file I get many errors. I am using Xcode 8.1.screen shot 2016-11-15 at 4 12 36 pm
Please help. Thanks

search bar clarification example

made some headway with tweaking designs on page.
But no so clear on rest of implementation details.
If I want a tableview inside view / how to rig this up?

I dropped in a tableview inside AppSearchBarController

the rootViewcontroller appears to not work.
Am I supposed to nest this in its own navigation controller?
is the back button supposed to pop / dismiss?

        let app = AppSearchBarController(rootViewController: UIViewController())
        
        
        let vc = OnboardingSuperstarsVC()
        let nc = UINavigationController(rootViewController: vc)
        nc.navigationBar.isTranslucent = false
        window?.rootViewController = nc
        window?.makeKeyAndVisible()
        
        nc.present(app, animated: true, completion: { 
            
        })
import UIKit
import Material
import Dotzu


class AppSearchBarController: SearchBarController,SearchBarDelegate {
    fileprivate var menuButton: IconButton!
    fileprivate var moreButton: IconButton!
    
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        Notificator.fireNotification(named: kFilterPressedClose)
    }
    
    open override func prepare() {
        super.prepare()
        prepareBackButton()
        prepareSearchBar()
        
      
        self.view.backgroundColor = wweColors.onyx
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        focusingSearchBar()
    }
    
    func focusingSearchBar() {
        
        guard let searchBar = searchBarController?.searchBar else {
            return
        }
        
        DispatchQueue.main.async {
            searchBar.textField.becomeFirstResponder()
        }
        
    }
    
    func reloadData(){
        
    }
    
    
  
    func searchBar(searchBar: SearchBar, willClear textField: UITextField, with text: String?){
         Logger.verbose("text:",text ?? "")
    }
    
    func searchBar(searchBar: SearchBar, didChange textField: UITextField, with text: String?) {
        guard let pattern = text?.trimmed, 0 < pattern.utf16.count else {
            reloadData()
            return
        }
        
        //https://github.com/lazarte/GraphSearch/blob/b8d7ea54a074838acba63f1fe084e71373ccfe77/Search/RootViewController.swift
        /*search.async { [weak self, pattern = pattern] (users) in
            guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {
                return
            }
            
            var data = [Relationship]()
            
            for user in users {
                if let name = user.object?["name"] as? String {
                    let matches = regex.matches(in: name, range: NSRange(location: 0, length: name.utf16.count))
                    if 0 < matches.count {
                        data.append(user)
                    }
                }
            }
            
            self?.tableView.data = data
        }*/
    }
    
    
}

extension AppSearchBarController {
    func didPressBackButton() {
        
        
//        self.transitionFromRootViewController(self.rootViewController)
        searchBar.textField.resignFirstResponder()
        self.navigationController?.pop()
    }
    fileprivate func prepareBackButton() {
        menuButton = IconButton(image: Icon.cm.arrowBack)
        menuButton.addTarget(self, action: #selector(didPressBackButton), for: .touchUpInside)
    }
    
    
    fileprivate func prepareSearchBar() {
        UIApplication.statusBarBackgroundColor = wweColors.darkLine
        searchBar.clearButton.tintColor = .white
        searchBar.clearButton.backgroundColor = wweColors.blackButtonColor
        searchBar.clearButton.layer.cornerRadius = 15
        searchBar.textColor = .white
        searchBar.textField.font = RobotoFont.medium(with: 20)
        searchBar.delegate = self
        searchBar.textField.keyboardAppearance = .dark
        searchBar.backgroundColor = wweColors.darkLine
        searchBar.placeholderColor = .white
        searchBar.leftViews = [menuButton]
        searchBar.backgroundColor = wweColors.onyx
        searchBar.textColor = .white
        searchBar.tintColor = wweColors.fireEngineRed

    }
}


CardTableView sample app missing base classes (won't compile)

The CardTableView demo sample project won't compile.
Specifically: AppFABMenuController
It is a subclass of FABMenuController (in the material framework), which I found a copy of online,
but that references
FabButton, FabMenuIem which are not in the current set of source files in the material framework.

why is my last icon on Toolbar lost on iphone 6S+ screen?

Hi,

I get this weird problem when trying to test my app on a larger screen.

======

Originally, I develop my app on an iphone 5S, on which everything is ok

img_0019

======

With the same code, I tried to run on an iPhone 6S+, my trash icon is gone:

img_0010

It seems that the Navigation Bar on the screen is too wide to fit in the screen. So I review the constraint in Storyboard, which is still good.

screen shot 2017-07-24 at 2 40 51 pm

My RootNavigationController is from the sample project:

import UIKit
import Material

class RootNavigationController: NavigationController {

    override func prepare() {
        super.prepare()
        
        guard let v = navigationBar as? NavigationBar else {
            return
        }
        
        v.depthPreset = .none
        v.dividerColor = Color.grey.lighten3
    }
    
}

Could you show me how I could fit the last icon on the wide screen?

Regards,

CardTableView 0 Articles

Working with CardTableView Sample but no card is displayed anything wrong with the setup of the project
Please check
screen shot 2017-06-24 at 12 28 23 pm
the screenshot for more details

Write story on Reminders.

This is a tutorial that takes a developer through the process of developing with the Reminders API in Material and storing it to Graph.

Transition ViewController in Storyboard

Hi all,

I'm new member of this project, I using NavigationDrawerController and implement LeftViewController as UITableViewController.

How to transition to new view when user click on table row item

Help required

Hi,
I am sorry I could not get back at the question you asked in the earlier issue,so I have reopened th issue.
This is the following status and more information
Xcode 8.1
Cocoapods 1.1.1

Now I try to run the script 'install_all_pods.sh'
which throws a lot of errors

screen shot 2016-11-18 at 11 58 07 am

Then I go inside the project
CosmicSamples/Material/Programmatic/Button
Then I run 'pod install'
I get the following error
screen shot 2016-11-18 at 11 59 29 am

I do what the error message tells me yet no change in the error message.
I guess that the something bad has happened but still I open the .xcworkspace and try to run then I get
"No such module 'Material' " error
This is the screenshot for your reference

screen shot 2016-11-18 at 12 02 20 pm

Images in PresenterCard doesn't load first time

I'm following the CardTableView sample, and I'm having trouble with showing the images.
Your example doesn't load the images until switching tab and going back.

screen shot 2017-02-06 at 11 57 12

My problem is related I think: I load the images from the network, which makes them appear after a second. The height of the cell is not correctly calculated, so the scroll area in the table view ends up too small.

What I would like (and this actually worked in an earlier version of Material): If I know I'm going to have an image later, set the height of the cell (or card) so it shows up blank but large. When the image is loaded, it just gets added, but the size stays the same (so the table doesn't flicker for the user).

This is how I set the height if I already know that an image is coming:

        if a.imageRef != nil {
            presenterImageView.height = imageHeight
        } else {
            presenterImageView.height = 0
        }
        if let image = activityImage {
            presenterImageView.height = image.height
            DispatchQueue.main.async { [weak self, image = image] in
                self?.presenterImageView.fadeTransition(0.6)
                self?.presenterImageView.image = image
            }
        } else {
            presenterImageView.image = nil
        }

Material Search Bar within a Navigation Controller

Hello! Is there an example of how to place the Material Search Bar in a Navigation Controller, inside of a Tab Bar Controller? So basically, a setup like Facebook mobile, but instead of their version of the search bar, it would show the Material search bar. I didn't see any examples, so I figured Id ask

Sample for TextView

Hi,

Just wondering if there is any sample available for TextView?

Thanks.

icons on tabbarItem

Hello everyone,

how can add icons on item tabs (pageTab...), and remove title text?

thanks very much.

Material CollectionView Sample Error

/Samples-master/Material/Programmatic/CollectionView/CollectionView/ViewController.swift:61:41: 'CollectionViewDataSource' cannot be constructed because it has no accessible initializers

Write story on Editor.

This is a tutorial that takes a developer through the process of developing with the Editor API in Material and storing it to Graph.

Write story on PhotoLibrary.

This is a tutorial that takes a developer through the process of developing with the PhotoLibrary API in Material and storing it to Graph.

Few issues w/XCode 8.2.1

Tried to build the CardTableView sample after running the install_all_pods script. Wasn't quite able to determine a solution. Running XCode 8.2.1 (8C1002).

  • Screen doesn't seem to be resolvable?
    /Samples-master/Graph/CardTableView/CardTableView/CardTableViewCell.swift:110:36: Use of unresolved identifier 'Screen'

  • AppDelegate.swift:54:36: Argument labels '(viewController:)' do not match any available overloads
    image

Disable NavigationDrawer in Pushed ViewController

Hi, i just have a question

i have a RootViewController (MainViewController With navidrawer and Menu Button(FAB))

let MainViewController: MainViewController = {
            return UIStoryboard.viewController(identifier: "MainViewController") as! MainViewController
        }()
        
        let NaviLeftViewController: NaviLeftViewController = {
            return UIStoryboard.viewController(identifier: "NaviLeftViewController") as! NaviLeftViewController
        }()
        
        let ApptoolBar =  AppNavigationController(rootViewController: MainViewController)
        
        let NaviDrawer =  AppNavigationDrawerController(rootViewController: ApptoolBar, leftViewController: NaviLeftViewController, rightViewController: nil)
        
        
        
        let SnackBar   =    AppSnackbarController(rootViewController: NaviDrawer)
        
        let Menu       = AppMenuController(rootViewController: SnackBar)
        
        
        UIApplication.shared.keyWindow?.rootViewController = Menu

when i push using the navigation controller the naviDrawer and the menu are shown in the Pushed View Controller

self.navigationController?.pushViewController(OrderBidsView, animated: true)

i can hide them and show in both viewControllers , but is there a way to hide the navidrawer and the menu in pushed view controllers instead of showing and hiding them manually?

Menu disappears when it is closed.

If you close a menu by tapping on the original menu button then the menu disappears. This only happens on a device, not in the simulator. It doesn't happen if you close the menu by tapping outside of it.

I've tested it on iOS 10.1 only and I'm using Xcode 8.1 and Material 2.3.22.

You can reproduce this in the MenuController sample project.

pageTabBarController

  1. how to change Tab bar position from bottom to top ?
  2. Can i add some button with imageView at tabBar ?

Error in Samples/AppToolbarController

Hi,

I found something in prepareStatusBar() {}

file: Programmatic/ToolbarController/ToolbarController/AppToolbarController.swift
line: 65

I think it's supposed to be:
statusBarController?.statusBar.backgroundColor = Color.blue.darken3
instead of:
statusBar.backgroundColor = Color.blue.darken3

Thanks

PhotoLibraryController not found

When I tried to subclass my view controller with PhotoLibraryController, it keeps on saying unidentified. Could anyone explain more about PhotoLibraryController class ?

use pagetabbar on top

Hello,

I want to use page tabbar on top but I couldn't move it to the top .

How can I make it ?

Thanks

fabButton method not found in Menu class

is the FABMenu class has been changed to Menu()? Because fabButton and fabMenuItems() methods are not found.
fabMenu.fabButton = fabButton
fabMenu.fabMenuItems = [notesFABMenuItem, remindersFABMenuItem]

my current pod is: pod 'Material', '~> 2.0'

Write story on Capture.

This is a tutorial that takes a developer through the process of developing with the Capture API in Material and storing it to Graph.

Add a sample for Card contentView being a UITableView

I have been having trouble getting UITableView to work inside Card. I tried to modify the Material/Programmatic/Card sample to have UITableView as Card's contentView, but it doesn't seem to scale correctly. Also I would like to get the row selection working. Here's the patch I applied to the sample:

diff --git a/Material/Programmatic/Card/Card/ViewController.swift b/Material/Programmatic/Card/Card/ViewController.swift
index 519921a..0f2a9ca 100644
--- a/Material/Programmatic/Card/Card/ViewController.swift
+++ b/Material/Programmatic/Card/Card/ViewController.swift
@@ -37,7 +37,7 @@ class ViewController: UIViewController {
     fileprivate var toolbar: Toolbar!
     fileprivate var moreButton: IconButton!
     
-    fileprivate var contentView: UILabel!
+    fileprivate var contentView: UITableView!
     
     fileprivate var bottomBar: Bar!
     fileprivate var dateFormatter: DateFormatter!
@@ -93,10 +93,10 @@ extension ViewController {
     }
     
     fileprivate func prepareContentView() {
-        contentView = UILabel()
-        contentView.numberOfLines = 0
-        contentView.text = "Material is an animation and graphics framework that is used to create beautiful applications."
-        contentView.font = RobotoFont.regular(with: 14)
+        contentView = UITableView()
+        contentView.delegate = self
+        contentView.dataSource = self
+        contentView.register(TableViewCell.self, forCellReuseIdentifier: "TableViewCell")
     }
     
     fileprivate func prepareBottomBar() {
@@ -124,3 +124,27 @@ extension ViewController {
     }
 }
 
+extension ViewController: UITableViewDelegate {
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return 60
+    }
+
+    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        print("Hello \(indexPath.row)")
+    }
+}
+
+extension ViewController: UITableViewDataSource {
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 5
+    }
+
+    /// Prepares the cells within the tableView.
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
+        cell.textLabel?.text = "Hello \(indexPath.row)"
+        cell.imageView?.image = Icon.addCircle
+        return cell
+    }
+}
+

Is there a way to disable placeholder animation while entering text.

Hello,
I am new to Material library.

i have a custom requirement where i don't want to have animation where placeholder of text fields animates to top left. But i do need other feature of Textfield.

I tried looking into implementation of Text Field but didn't find anything concrete. Please suggest.

[PageTabBar] Transition to another page

How to make transition to another page via code?
So far i have done this by changing access modifier of handlePageTabBarButton from internal to public. However this is for sure not the proper way of doing this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.